- From: Ben Kelly <notifications@github.com>
- Date: Wed, 11 Jan 2017 07:07:45 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 11 January 2017 15:08:19 UTC
To adjust my original example code I think we agreed to this:
```
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(_ => {
// But if there is an extra microtask turn here...
Promise.then(_ => {
// Then this should throw.
evt.waitUntil(fetch(evt.request));
});
});
// promise resolves at some point...
setTimeout(_ => resolveOuterPromise(), 100);
});
```
So I think queuing a full up task is wrong.
--
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#issuecomment-271892473
Received on Wednesday, 11 January 2017 15:08:19 UTC