Re: [w3c/ServiceWorker] Proposal: Allow addEventListener/removeEventListener for 'fetch' to called at anytime (#1195)

> It doesn't allow a running SW to stop handling fetch events and avoiding its overhead.

So you're saying the overhead of the fetch is greater than the network request itself? What kind of delay are you seeing? I'm asking this because I'd like to try and recreate is issues you're seeing, so we can figure out if this is a Chrome problem, or a fundamental spec issue that needs addressing. We have https://github.com/jakearchibald/service-worker-benchmark – does this show the kind of issue you're seeing?

> It will cause preload fetch to go out to network for resources that will be clearly cached consuming valuable bandwidth

I don't see how this is different in your proposal.

> `serviceWorker.fetch.disable()` isn't great either even if we also added `enable()`. I think it's bad practice to not deliver a `fetch` event if there's any remaining `fetch` listener(s) that have not been unregistered.

I'm not really sure what this means. Can you provide some more details?

> It's also a bad API if we ask users to call `serviceWorker.fetch.disable()` rather then `removeEventListener`

In terms of discussing the merits of APIs, can we do better than "it is bad"? I think in https://github.com/w3c/ServiceWorker/issues/1195#issuecomment-331979521 I used code examples to show disadvantages in the API you proposed rather than just declaring it "bad". Could you extend the same courtesy to me? In fact, I held off on pointing out flaws in your API at all until you demanded it – instead I wanted to bypass that and discuss the problem.

Before we start proposing new APIs to solve problems that are only created by proposed APIs, can we stick to defining the source and extent of the issue?

https://github.com/whatwg/dom/issues/371 should be solved by limiting the error throwing to events on the service worker global. This rule is in place to alert the developer to the footgun of adding listeners async, which will result them missing events. Your proposal doesn't change this, so it's a bit of a red herring.

-- 
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/1195#issuecomment-333809071

Received on Tuesday, 3 October 2017 11:03:49 UTC