Re: [w3c/ServiceWorker] async waitUntil microtask issue (#1213)

Thanks for clarifying with the tests, @aliams. I think we mostly agree on the current spec behavior for `waitUntil()`, but would like to clarify some points:

> I was thinking maybe we could make it respect the dispatch flag here, but the "keep alive token" is created on another thread. It would be very difficult to do this in firefox.

@wanderview, do you still have this issue or is it implementable? I thought of using event's _extend lifetime promises_ for checking "extension promises were added" condition in your comment, but we still don't solve https://github.com/w3c/ServiceWorker/issues/1213#issuecomment-342640579 case without the dispatch flag.

Having thought on it, (throwing when the dispatch flag is unset && count == 0) explains the desired behavior well I think. That is, the event is basically extendable during its own task turn and during when the extension opportunity isn't closed.

Other than that, I'm a bit uncomfortable with the following cases. What do you think about them?

```js
const p = async_task_waituntil();
event.waitUntil(p);
p.then(() => { Promise.resolve().then(() => event.waitUntil(q)) }); // Throw.
```
This throws since the count decrement microtask queued by waitUntil step 5 will run before the microtask queued by p.then callback.

```js
const p = async_task_waituntil();
p.then(() => { Promise.resolve().then(() => event.waitUntil(q)) }); // OK.
event.waitUntil(p);
```
This runs OK since the count decrement microtask queued by waitUntil step 5 will run after the microtask queued by p.then callback.

-- 
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/1213#issuecomment-358293981

Received on Wednesday, 17 January 2018 12:48:30 UTC