Failed to execute 'put' on 'Cache': Entry already exists.
OysteinAmundsen opened this issue · comments
Library Affected:
workbox-strategies v7.0.0
Browser & Platform:
Google Chrome v116 and v117
Issue or Feature Request Description:
I have a service-worker using the following code:
declare const self: ServiceWorkerGlobalScope | any;
clientsClaim();
self.skipWaiting();
cleanupOutdatedCaches();
// This is prefilled using workbox-webpack-plugin.InjectManifest
// precacheAndRoute(self.__WB_MANIFEST);
// Cache the Google Fonts stylesheets with a stale-while-revalidate strategy.
registerRoute(
/^https:\/\/fonts\.googleapis\.com/,
new StaleWhileRevalidate({
cacheName: `fonts`,
})
);
As you can see, I only have one route here using the StaleWhileRevalidate
strategy. When run, the workbox-strategies.StrategyHandler
class throws an error when placing response to cache. The error message is:
Failed to execute 'put' on 'Cache': Entry already exists.
No stack-trace is provided for the error, but when debugging I've traced it back to here:
try {
// Every Strategy I've tried fails here:
await cache.put(effectiveRequest, hasCacheUpdateCallback ? responseToCache.clone() : responseToCache);
}
catch (error) {
if (error instanceof Error) {
if (error.name === 'QuotaExceededError') {
await executeQuotaErrorCallbacks();
}
throw error;
}
}
This results in the Cache Storage being empty. This also errs in v6.5.4.
I've tested my code in FireFox v117 also. The cache does fill up there, and I see that requests are served from the service-worker.
Issue is also posted on StackOverflow: https://stackoverflow.com/questions/77132806/every-workbox-strategy-returns-failed-to-execute-put-on-cache-entry-alread
This is probably not an issue. It works fine in incognito mode, and in other browsers than one particular chrome instance. Must be a local problem on this instance of chrome. I'm closing this issue.