Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

service-worker can block POST requests if cache fails #33793

Closed
apocalyp0sys opened this issue Nov 13, 2019 · 2 comments

Comments

@apocalyp0sys
Copy link
Contributor

@apocalyp0sys apocalyp0sys commented Nov 13, 2019

馃悶 bug report

Affected Package

The issue is caused by package @angular/service-worker

Description

I've ran into another caching problem. When handling POST (or any mutating) fetches, service-worker tries to invalidate cache for the corresponding url and re-write LRU table. LRU table is stored in CacheStorage. If writing to cache fails, no fetch is called and no request is made.

馃敩 Minimal Reproduction

Not easily doable, may provide a repo/virtual machine later, if needed

  1. Create an a application with ngsw
  2. Define a dataGroup in ngsw-config.json
  3. Fill up system disk (found no other reliable way to reduce available cache size)
  4. Make a POST request to a url defined in dataGroup

馃敟 Exception or Error

Uncaught (in promise) DOMException: Quota exceeded.
POST {{url here}} net::ERR_FAILED

馃實 Your Environment

Angular Version:


8.2.13
@apocalyp0sys

This comment has been minimized.

Copy link
Contributor Author

@apocalyp0sys apocalyp0sys commented Nov 13, 2019

The uncatched error is thrown here.

return table.write('lru', this._lru !.state);

return this.cache.put(this.request(key), this.adapter.newResponse(JSON.stringify(value)));

There were cache-failure related issues previously, maybe we should wrap all cache-wrinting calls in try?

@gkalpak

This comment has been minimized.

Copy link
Member

@gkalpak gkalpak commented Nov 13, 2019

Ouch, good catch! Yeah, it might make sense to make the LRU syncing methods more resilient to errors (instead of error-proofing all call-sites).

apocalyp0sys added a commit to apocalyp0sys/angular that referenced this issue Nov 20, 2019
鈥ure

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 angular#33793
apocalyp0sys added a commit to apocalyp0sys/angular that referenced this issue Nov 21, 2019
鈥ure

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 angular#33793
apocalyp0sys added a commit to apocalyp0sys/angular that referenced this issue Nov 21, 2019
鈥ure

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 angular#33793
apocalyp0sys added a commit to apocalyp0sys/angular that referenced this issue Nov 22, 2019
鈥ure

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 angular#33793
matsko added a commit that referenced this issue Nov 22, 2019
鈥ure (#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
@matsko matsko closed this in 621b659 Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can鈥檛 perform that action at this time.