[w3c/ServiceWorker] Possible race between Activate and Update Algorithms (#1285)

Consider the case of a service worker which always fails the byte check comparison because the web server generates the script dynamically and calls registration.update() in the activate event handler.
``` 
 // some unique random string dynamically generated by the web server
 onactivate = function(e) {
 e.waitUntil(self.registration.update());
}
```

In step 12 of the activate algorithm we need to wait for all waitUntil promises to resolve/reject before
invoking Update Worker State passing _activated_ as an argument. self.registration.update() is resolved as a result of a job queued in step 6 of the install algorithm. 
At this point, the registration has an installing worker and a waiting worker. Now, if the install algorithm reaches step 15.1 and terminates the waiting worker **before** the promise is resolved, it will never reach "activated" state (step 13 Activate Algorithm).

This is currently observable in Firefox, listening for worker state changes when registering this script, will reach either "activating" or "activated".


-- 
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/1285

Received on Wednesday, 7 March 2018 18:21:02 UTC