Re: [ServiceWorker] Describe waitUntil() behavior in terms of Promise.all() (#738)

We're already using Promise.all() for waitUntil().

> While the event is dispatching (since waitUntil() can't be called when async), every promise passed to it is appended to an array. 

[event object's extend lifetime promises](https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#dfn-extend-lifetime-promises) is an array of promises to keep the list of the added promises.

> At the end of the dispatch wait on Promise.all(list of promises). That way we get 'rejection gets priority' for free.

The task runs the waitUntil() is actually doing this: "[waiting for all of](http://www.w3.org/2001/tag/doc/promises-guide#waiting-for-all) extendLifetimePromises settles."

It's sort of double-defined once in **waitUntil()'s task algorithm's step 3** and **Install algorithm step 11.5 and Active algorithm step 15.5**.

May be we can try to simplify this bit by reducing one side of such steps, but on one hand I think it seems easier to understand the relationship of those algorithms as-is.

And [waiting for all of](http://www.w3.org/2001/tag/doc/promises-guide#waiting-for-all), the algorithm description for Promise.all, is already giving us 'rejection gets priority' semantic as you pointed.

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

Received on Monday, 24 August 2015 07:51:00 UTC