[slightlyoff/ServiceWorker] clarify behavior when fetch event handler throws (#896)

Currently the spec seems clear that this should not trigger a network error:

```
addEventListener('fetch', function(evt) {
  throw('boom');
});
```

I think it says this should trigger a network error, though:

```
addEventListener('fetch', function(evt) {
  evt.respondWith(new Response('hmm'));
  throw('boom');
});
```

Because step 18 of Handle Fetch says to set `handleFetchFailed` to true if the task is discarded.  And then we don't enter step 20 because `respondWithEntered` is true.  So we should enter step 21 and trigger a network error.

(Note, because the response passed to `respondWith()` is coerced to a Promise by webidl the exception will by thrown before `respondWith()` is fulfilled with the Response.)

Talking with @jakearchibald, though, it seems we should just accept the value passed to `respondWith()` in this case.  This is what chrome currently does.

If this is the desired behavior we should fix the spec to handle that case.  We probably need a separate flag from `handleFetchFailed` to note synchronous event handler failures.

Firefox currently treats all of these examples as a network error.  I'm going to write a bug to fix that.

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

Received on Tuesday, 10 May 2016 16:12:18 UTC