question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

service-worker: properly handle storage quota problems

See original GitHub issue

Discussion taken here from angular/angular-cli#8592.

I’ve been experiencing this issue on Chrome, however, it seems to be applicable to any browser in one way or another.

When you run low on disk space (and most likely other occasions), Chrome cuts the storage quota to zero and Uncaught (in promise) DOMException: Quota exceeded. is thrown during service worker installation. When the issue appeared navigator.storage.estimate() would always return an object with quota === usage, both being about the service worker script size.

I see that this is a browser limitation, but DOMException: Quota exceeded. and similar errors on other browsers should be caught and an event passed to the angular service.

Unfortunately I don’t see a way to reproduce the issue other than filling up your main disk.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
apocalyp0syscommented, Oct 4, 2019

@gkalpak Did some more digging and decided we shouldnt cattch the error here

https://github.com/angular/angular/blob/f3859ff2b9aa75068250aa1ce4b117c6adfccf3c/packages/service-worker/worker/src/driver.ts#L445

It can be not cache-related and break something else. Also unable to get actual response at this point, would have to re-run network request.

Decided to fix this while handling reqests by data group strategy, please see PR.

1reaction
apocalyp0syscommented, Sep 19, 2019

We’ve encountered this error after moving our application from self-made service worker to ngsw. This error is important because it can cripple the ngsw and prevent it from serving any requests at all (both from cache and network) when the user has no free disk space available. It is hard to reproduce, cant find any browser flags or configuration parametes to reduce CacheStorage size, ended up just filling system disk.

This error occurs when ngsw tries to put something in cache and errors are not handled properly in some cases.

When the error occurs during initialization (asset caching), it is catched and ngsw enters SAFE_MODE. After this all is served from network and the client works ok.

https://github.com/angular/angular/blob/f3859ff2b9aa75068250aa1ce4b117c6adfccf3c/packages/service-worker/worker/src/driver.ts#L403

When the error occurs during data (api) caching, the error is catched and rethrown, no respondWith is called, and the client is left with no data (status code 0, as if no connection available)

https://github.com/angular/angular/blob/f3859ff2b9aa75068250aa1ce4b117c6adfccf3c/packages/service-worker/worker/src/driver.ts#L445

Probably we should detect if the error is QuotaExceeded and switch to SAFE_MODE in this case. Or do not rethrow error at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing buggy service workers - Chrome Developers
How to fix a service worker that is causing problems.
Read more >
Using Service Workers - Web APIs | MDN
Service workers fix these issues. Using a service worker you can set an app up to use cached assets first, thus providing a...
Read more >
What is the storage limit for a service worker?
I would say it's a limit of the sandbox which specifies the amount of memory and CPU+IO resources available for each page at...
Read more >
What is the Service Worker ⚙️ Cache Storage Limit? How ...
The Service worker cache limit ranges by browser and device constraints. Capacity typically starts at 50MB & ranges up to 20GB, with caveats ......
Read more >
ServiceWorker is shut down every 5 minutes for manifest ...
My MV3-version of my extension is on hold because of this issue. Please fix this Google… I've got an extension which also has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found