[w3c/ServiceWorker] async waitUntil() detail missing? (#1039)

I feel like we discussed this case at one point, but can't find where:

```
addEventListener('fetch', evt => {
  // keep alive the SW based on some promise
  let resolveOuterPromise;
  let p = new Promise(resolve => resolveOuterPromise = resolve);
  evt.waitUntil(p);

  // Code can be defined to run on the final keep alive promise resolution that
  // then keeps the SW alive again.
  p.then(_ => {
    // I think the spec says this should throw, but I thought we agreed this should work.
    evt.waitUntil(fetch(evt.request));
  });

  // promise resolves at some point...
  setTimeout(_ => resolveOuterPromise(), 100);
});
```

I don't think the spec allows this as currently written.  Step 4 here:

https://w3c.github.io/ServiceWorker/#extend-service-worker-lifetime-algorithm

Unsets the flag allowing extension immediately after the current set of extension promises settles in step 2.  I think this blocks the addition of new extension promises?

Or is there something which guarantees other .then() handlers will run between step 2 and 3 here?

I think we should either explicitly have a microtask to run step 3/4 or run add a comment about some hidden invariant which results in this outcome.

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

Received on Wednesday, 21 December 2016 22:31:47 UTC