fix(service-worker): allow creating post api requests after cache failure (#33930)
Before creating a mutating http request, service-worker invalidates lru cache entry and writes to cache storage. Therefore, cache storage failure can prevent making post requests. Fix this by catching and logging cache error, add a test case. Fixes #33793 PR Close #33930
This commit is contained in:

committed by
Matias Niemelä

parent
aa4d2b785b
commit
63c9123924
@ -275,7 +275,15 @@ export class DataGroup {
|
||||
return;
|
||||
}
|
||||
const table = await this.lruTable;
|
||||
return table.write('lru', this._lru !.state);
|
||||
try {
|
||||
return table.write('lru', this._lru !.state);
|
||||
} catch (err) {
|
||||
// Writing lru cache table failed. This could be a result of a full storage.
|
||||
// Continue serving clients as usual.
|
||||
this.debugHandler.log(err, `DataGroup(${this.config.name}@${this.config.version}).syncLru()`);
|
||||
// TODO: Better detect/handle full storage; e.g. using
|
||||
// [navigator.storage](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorStorage/storage).
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user