Cache.put() call fails after deleting the Cache object
Reported by
marty...@puronas.me,
Aug 13 2016
|
||||||
Issue description
Chrome Version : 52.0.2743.116 (Official Build) m (32-bit) Windows 8.1
52.0.2739.0 (Official Build) unknown (64-bit) Ubuntu 16.04
URLs (if applicable) : https://martynas-p.github.io/chrome-cache-bug/
What steps will reproduce the problem?
(1) Navigate to https://martynas-p.github.io/chrome-cache-bug/
(2) Once the service worker is registered, delete the my-cache Cache Storage from the Application tab in the console (that is the actual Cache object, not just the requests stored in it)
(3) Refresh the page
What is the expected result?
After the page is refreshed, it should create a new Cache object with the name my-cache and store the requests that were put there by the service worker for later retrieval.
What happens instead?
An exception appears in the console (Uncaught (in promise) DOMException: Entry was not found.undefined:1. Looking at the stacktrace, it seems that the exception was thrown during the cache.put() call) which suggests that it could not find the Cache object with that name even though
a) it appears in the Application tab in the Developers' console
2) the cache.put() is called from a promise which is returned from opening my-cache Cache object (caches.open('my-cache'))
I tried to make sure that the cache object exists when the page is loaded and before any attempts are made to store it, e.g. on the actual page I have
<script type="text/javascript">
caches.open('my-cache').then(() => {
navigator.serviceWorker.register('sw.js');
});
</script>
and the 'fetch' event handler inside the service worker
self.addEventListener('fetch', (event) => {
event.respondWith(caches.open('my-cache').
then(cache =>
cache.match(event.request).then(response => {
return response || fetch(event.request).then(response => {
cache.put(event.request, response.clone());
return response;
});
})
)
);
});
as well as in the 'install' event handler
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open('my-cache')
.then((cache) => {
return cache.addAll([
'',
'some-assets.js'
]);
})
);
});
The exception is not thrown if the individual requests are deleted.
Code of the website which reproduces the issue can be found at https://github.com/Martynas-P/chrome-cache-bug
Let me know if you need any more details
Thanks!
Martynas
,
Aug 17 2016
Able to reproduce the issue on Windows-10, Ubuntu 14,04 and Mac OS 10.11.6 using chrome latest stable M52-52.0.2743.116 by following steps mentioned in the original comment, Observed the error saying "Uncaught (in promise) DOMException" in console. Tested the same on older versions of chrome M35-35.0.1849.0 and observed different error saying "Uncaught SyntaxError: Unexpected token" .
,
Aug 19 2016
I could also reproduce this. jsbell@, could you handle this issue?
,
Aug 24 2016
cmumford@ - can you take a look?
,
Jun 2 2017
,
Jun 4 2018
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Aug 8
I attempted to reproduce using the #c0 steps. It appears to work correctly now. Please let us know if you see it again. Thanks. |
||||||
►
Sign in to add a comment |
||||||
Comment 1 by pauljensen@chromium.org
, Aug 15 2016