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:
Denis Omelkov
2019-11-21 16:09:46 +05:00
committed by Matias Niemelä
parent aa4d2b785b
commit 63c9123924
2 changed files with 30 additions and 1 deletions

View File

@ -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).
}
}
/**