[ServiceWorker] skip waiting flag purges active worker early (#821)

In Install we have:

```
 19) If registration's waiting worker's skip waiting flag is set, then:
   1)  For each service worker client serviceWorkerClient whose creation url
         matches registration's scope url:
       1) Let exitingWorker be the active worker that controls serviceWorkerClient.
       2) If exitingWorker is not null, then:
           1) Wait for exitingWorker to finish handling any in-progress requests.
           2) Terminate exitingWorker.
           3) Run the Update State algorithm passing exitingWorker and redundant as
               the arguments.
   2) Run Activate algorithm, or its equivalent, passing registration as the argument.
```

I don't understand why we need to exit the active worker at this point when Activate exits the worker immediately in its step 4.

This is an issue because Activate can be async (or is [always async depending how you treat the job logic][]).  That means we have a window here with no active worker which can then result in functional events not firing on a service worker at all.

I think it would be better to remove the exiting worker logic from the install skip-waiting-flag handling and just rely on Activate to exit the worker.

[always async depending how you treat the job logic]: https://code.google.com/p/chromium/issues/detail?id=530085

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

Received on Thursday, 21 January 2016 15:41:43 UTC