DEV Community

loading...

Discussion on: PWAs that download like apps ๐Ÿ—œ๏ธ

Collapse
jeffposnick profile image
Jeff Posnick

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.

Collapse
samthor profile image
Sam Thorogood Author • Edited

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.

Collapse
jeffposnick profile image
Jeff Posnick

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.

Forem Open with the Forem app