- From: Daniel Huigens <notifications@github.com>
- Date: Thu, 18 Jan 2018 16:33:56 +0000 (UTC)
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 18 January 2018 16:34:19 UTC
I think I've found a workaround to this issue: instead of calling (the nonexistent) `waitUntil` in an `updatefound` event, call `waitUntil` from a preceding functional event (e.g. `fetch`). I believe all Service Worker updates will be preceded relatively shortly by a functional event, be it a `fetch` event during the page load which triggered an update, or a functional event that itself triggered the update, although it's not guaranteed: "The user agent *may* call [the Soft Update algorithm] as often as it likes to check for updates." (Please correct me if I'm wrong and browsers actually do this.) Another downside is that, AFAICT, you have to register for *all known functional events*, because if you don't and it fires, the Service Worker is updated but not started (https://w3c.github.io/ServiceWorker/#handle-functional-event-algorithm, step 4.2). That is of course impractical and bad for performance (since the SW is uselessly started and made to keep running with `waitUntil()` if an update isn't found), so it would still be nice to have `waitUntil()` on `updatefound` events. (And also because, as mentioned, this workaround is not guaranteed to be correct.) -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/issues/1208#issuecomment-358702735
Received on Thursday, 18 January 2018 16:34:19 UTC