-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
should EventSource bypass service worker interception? #885
Comments
WebSocket is special in that it's an HTTP handshake and then uses the connection for something else. EventSource is just like any other API that fetches something, it's just by design a longer-lived transaction, but that is not too different from |
Also, in the no-streams scenario the service worker would just return the response from the server directly and then the user agent can close the service worker, right? There's no need to wait for end-of-file unless the developer is trying to observe it. And again, that would be no different from other places that fetch. |
Anne's explanation sounds right to me |
Yes, but I believe the browser will immediately trigger another connection unless you send evenetsource content providing a retry delay, etc. So in the naive case it will keep spinning up the service worker over and over again. |
If the connection closes for some reason, sure. But that's not the common scenario and also does not seem like a good enough reason. It's still equivalent to all other things that fetch. |
Well, "closes for some reason" means passing anything to I'm fine continuing to intercept EventSource. To be honest, I doubt many people will ever run into this interaction. Its just a bit wonky to use with ServiceWorkers. |
Passing a network response (whose body is streaming) to it should work, no? |
Right. It should. I'll just close this for now. |
…e worker onFetch implementation and lets the browser handle the request, specific to angular. Background on root issue w3c/ServiceWorker#885 Issue leading to work around angular/angular#21191 Workaround that checks for the header petersalomonsen/angular@c7b357a
Currently we support intercepting EventSource. I'm even adding a wpt test for this since its a way to observe a different FetchEvent.request.cache value.
While writing that test, though, it became apparent that EventSource is currently difficult to use with ServiceWorker. EventSource is designed with the idea that the connection will be held open and lines will be flushed across the connection to trigger events. This is quite difficult to do today with synthetic responses. It might be possible in the future with streams, but you would still have to hold the SW alive.
@sicking suggested that we might want to treat EventSource like WebSocket and just bypass the service worker for now.
I feel like this is kind of a low priority item, but wanted to file the issue so we don't lose track of it.
The text was updated successfully, but these errors were encountered: