Re: [w3c/ServiceWorker] Central algorithm for updating service worker state and registrations (#1416)

Summary for folks arriving here for the first time:

When *newWorker* (a service worker) is promoted from "waiting" to "active", overwriting *oldWorker* (another service worker), the following happens:

1. *oldWorker*'s state becomes `"redundant"`.
1. *newWorker*'s state becomes `"activating"`.
1. `registration.waiting` becomes `null`.
1. `registration.active` becomes *newWorker*.

The current version of the spec performs this update over 4 separate tasks in a single realm, meaning JavaScript can run in between and observe a half-updated state. All updates to JS objects & related events follow this pattern.

I'm proposing we switch to a single task per event loop, where the objects are updated, then the events are fired.

@wanderview suspects this would be a massive amount of work for Firefox. @matto is looking into it for Chrome.

If it makes things easier for implementers, it's probably fine to fire events over a series of tasks. However, I think we should aim to have *all* JS objects updated before firing any of the related events.

-- 
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/pull/1416#issuecomment-500362009

Received on Monday, 10 June 2019 10:04:12 UTC