In issue https://bugs.chromium.org/p/chromium/issues/detail?id=756193 the reporter had trouble with their CacheStorage ops failing because the profile got corrupted and so disk_cache::CreateCacheBackend was failing. Arguably, in this case Chrome should be doing something itself (like dropping the cache).
The easy way of doing it is to pass true to force=true to CreateCacheBackend, but that might not have the right semantics as it will only affect that one cache dir.
Easy-ish way to demo:
cache_storage.html:
<script>
caches.open("test").then(function(c) {
c.keys().then(function(a) {
alert("keys:" + a);
}
).catch(function(e) {
alert("exception calling keys:" + e);
}
);
}).catch(function(e) {
alert("exception:" + e);
});
</script>
----
1. Run chrome with a temp/empty profile, create the cache dir:
out/Default/chrome --user-data-dir=/tmp/cr ~/cache_storage.html
(works fine)
2. Close chrome
3. Simulate corruption:
cat /dev/null > /tmp/cr/Default/Service\ Worker/CacheStorage/*/*/index
4. Run chrome again.
out/Default/chrome --user-data-dir=/tmp/cr ~/cache_storage.html
Now get an exception, and keep getting it unless someone calls CacheStorage.delete (or nukes the profile)
Comment 1 by michaeln@chromium.org
, Aug 23 2017