Re: [w3c/ServiceWorker] Consider throwing when non-promise is passed to `waitUntil`. (#1068)

To clarify, the problem I have is the following:

The following code will add `index.html` and `styles.css` to my cache:
```js
self.oninstall = event => {
  event.waitUntil(async function() {
    const cache = await caches.open('mycache');
    await cache.addAll(['index.html', 'styles.css']);
  }());
}
```

The following code will do _nothing_:
```js
self.oninstall = event => {
  event.waitUntil(async function() {
    const cache = await caches.open('mycache');
    await cache.addAll(['index.html', 'styles.css']);
  });
}
```

The only difference is that I forgot to invoke my async function literal. I would like to somehow catch that. 

> Maybe we just need to push a pattern like:

I guess we could try solving this by pushing best practices, but I feel like there’s barely ever a use-case where the value passed to `waitUntil` is anything else but a promise[citation needed]. I do understand @annevk that IDL does not allow us to inspect the value passed to `waitUntil`, but I’d still like us to at least think about if there’s a feasible solution to making this error for developers’ sake.

-- 
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/1068#issuecomment-278339634

Received on Wednesday, 8 February 2017 14:16:16 UTC