From eyeballing your code, that promise passed to the install event's waitUntil() seems like it might resolve too early (it's not waiting for the untar() callback), and also would resolve even if the cache.put() call rejected.
Generally, you'd want to make sure that the promise passed to an install event's waitUntil() only fulfills iff all of the content that needs to be cached was successfully saved, and rejects otherwise.
Rejecting that waitUntil() promise will cause the newly registered service worker to enter the redundant state. The next time the same service worker gets registered, the install process will then run again—and hopefully everything will be properly cached during that subsequent attempt.
The call to untar in this case is actually totally synchronous so all the callbacks arrive before the async handler resolves. I modified the library which did use a Web Worker... anyway, the callback is fairly misleading- I'll fix it up.
Gotcha about the callback. But the cache.put() part could definitely fail asynchronously, which is not uncommon if you're, for instance, out of storage quota for your origin.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
From eyeballing your code, that promise passed to the
install
event'swaitUntil()
seems like it might resolve too early (it's not waiting for theuntar()
callback), and also would resolve even if thecache.put()
call rejected.Generally, you'd want to make sure that the promise passed to an
install
event'swaitUntil()
only fulfills iff all of the content that needs to be cached was successfully saved, and rejects otherwise.Rejecting that
waitUntil()
promise will cause the newly registered service worker to enter theredundant
state. The next time the same service worker gets registered, theinstall
process will then run again—and hopefully everything will be properly cached during that subsequent attempt.The call to
untar
in this case is actually totally synchronous so all the callbacks arrive before theasync
handler resolves. I modified the library which did use a Web Worker... anyway, the callback is fairly misleading- I'll fix it up.Gotcha about the callback. But the
cache.put()
part could definitely fail asynchronously, which is not uncommon if you're, for instance, out of storage quota for your origin.