Re: [slightlyoff/ServiceWorker] should async waitUntil() work in .then() handler of promise passed to previous waitUntil()? (#935)

I guess the "waiting for all" here:

> Wait until the result of waiting for all of extendLifetimePromises settles. 

Explicitly links to the Promise.all() algorithm.  So I guess this is defined and this should work:

```
addEventListener('fetch', e => {
  let respondWithPromise = fetch(e.request);
  respondWithPromise.then(response => {
    let clone = response.clone();
    e.waitUntil(caches.open('db').then(cache => {
      return cache.put(e.request, clone);
    });
  });
  e.respondWith(respondWithPromise);
});
```

But this would trigger a throwing waitUntil():

```
addEventListener('fetch', e => {
  let respondWithPromise = fetch(e.request);
  e.respondWith(respondWithPromise);
  respondWithPromise.then(response => {
    let clone = response.clone();
    e.waitUntil(caches.open('db').then(cache => {
      return cache.put(e.request, clone);
    });
  });
});
```

This is fine with me since its clearly defined.  Jake did suggest in person, though, that maybe we should wait a micro task turn to allow both of these cases to work.  Thoughts?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/935#issuecomment-235775927

Received on Thursday, 28 July 2016 01:54:28 UTC