-
Notifications
You must be signed in to change notification settings - Fork 831
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling of quota exceeded errors in workbox-precaching #1312
Comments
Thinking out load some more: we might be able to address this inside of the That would have the benefit of not requiring developers to change the way they register their service workers, and we would more context about which caches/IDB entries need to be deleted if the cleanup happened inside of our service worker. |
|
@jeffposnick In the case of Safari 11.1, it doesn't support the I'm trying to tackle this problem in general regardless of the browser. The plan is to delete all the known caches generated by our service worker. |
Would like to see a solution for this! |
Very interesting, thanks @raejin |
@jeffposnick Since we've updated from Workbox 2 to 3, we have
What are the solutions ? In v2 it worked fine, maybe because there was no |
There's not a specific solution in place for Workbox v3. You'd have to trim down the amount/size of URLs that you're precaching. Coming up with an automated solution is going to require more thought, and is not something that we've been able to address yet. |
@jeffposnick I am currently using the code: navigator.serviceWorker
.register(swPath})
.then((registration) => {
registration.addEventListener('updatefound', () => {
const installing = registration.installing;
if (installing) {
const onInstallingStateChange = () => {
if (installing.state === 'redundant') {
// redirect
// or alert about quote error
}
if (installing.state === 'installed') {
installing.removeEventListener('statechange', onInstallingStateChange);
resolve(registration);
}
};
installing.addEventListener('statechange', onInstallingStateChange);
}
});
})
.then((registration) => {
// start app
}) |
Hello @budarin—there's no one-size-fits all solution here, so we've kept this open to track possibilities. Listening for an Alternatively, if you wanted to perform some asynchronous action from inside your your service worker when there's a quota error, you can use In the future, we may expose a |
Hi @jeffposnick ! Is there any workbox precache method or callback params method to clear pre cache in case of quota exceeded error? |
Clearing the cache can be done with the standard Cache Storage API methods: import {cacheNames} from 'workbox-core';
// Call this as your custom quota error callback, or anywhere else:
async function deletePrecache() {
await caches.delete(cacheNames.precache);
} Note that the next time the service worker installs, it's going to retry caching all the items in the precache manifest. So you might just end up redownloading everything and then running into quota issues again, unless the user also frees up additional space on the device or unless you reduce the size of your precache manifest. |
Hi there, Workbox is moving to a new engineering team within Google. As part of this move, we're declaring a partial bug bankruptcy to allow the new team to start fresh. We realize this isn't optimal, but realistically, this is the only way we see it working. For transparency, here're the criteria we applied:
Thanks, and we hope for your understanding! |
Library Affected:
workbox-precaching
This is closely related to #1308, but the exact analog is GoogleChromeLabs/sw-precache#345
Let's leave runtime caching aside for this issue, and assume that there's a web app instance that has revision N of their assets precached. The web app is updated and deployed, and now there's an attempt to download and cache a few of the new/updated assets that make up revision N+1.
workbox-precaching
does this in theinstall
handler, and will fail installation if any of the individualcache.put()
operations fail. (Since all the assets from revision N are still cached at this point, it's not too hard to imagine scenarios in which caching the new assets brings you over quota.)From the point of view of the web page clients, there are events fired on the associated service worker registration showing the service worker progressing from the
installing
state to theredundant
state. Unless (somehow) quota is freed up at some point, thatinstalling
->redundant
transition will happen indefinitely, leaving the user stuck revision N of all the precached assets indefinitely.We should do something to help developers out here. What about a pattern like:
and then encapsulate all that logic in the hypothetical new module described in #1129?
The text was updated successfully, but these errors were encountered: