Re: [ServiceWorker] Race when registering multiple service workers for the same scope (#783)

So, having implemented this, I can see there are still some races:

0) Start with an active worker with script A.
1) A register() adds an Update job with script B to the update queue.
2) Add a second Update job with script A to the update queue.
3) The first Update is popped off the update queue, verifies that we are registering a new script, and queues an Install job for script B in the install queue.
4) The second Update job is popped off the update queue.  It still just sees the script A active worker as the newest worker, so thinks its ok to update with script A.  It also queues an Install job, but with script A.
5) Install job for script B runs.
6) Install job for script A runs.

End result is we lose the registration of script B.

To help close this race I'm trying to check for changes in newest worker script URL right before queuing the install job from an update, but I think there is still the potential for a race.

If the install was performed as part of the same job as the update this race would not exist.  We could not start the next update until the previous install had completed.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/783#issuecomment-164813284

Received on Tuesday, 15 December 2015 16:16:05 UTC