EventSource (SSE) throws JS error on page reload
Categories
(Core :: DOM: Core & HTML, defect, P5)
Tracking
()
People
(Reporter: dana, Unassigned)
References
()
Details
Attachments
(3 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.28.8 (KHTML, like Gecko) Version/6.0.3 Safari/536.28.8 Steps to reproduce: Created an EventSource, verify it is connected, reload page. Actual results: Receive console error "The connection to http://<hostname>/<path>/eventsource.php was interrupted while the page was loading." Expected results: The EventSource should have closed silently.
Reporter | ||
Updated•12 years ago
|
Reporter | ||
Updated•12 years ago
|
Reporter | ||
Comment 2•12 years ago
|
||
This is a server php script to demonstrate this bug.
Reporter | ||
Comment 3•12 years ago
|
||
Updated•12 years ago
|
Updated•12 years ago
|
Olli or Masatoshi-san, could you have a look at what's happening here?
Comment 5•12 years ago
|
||
We just print stuff to console as expected, but I guess we should try to not do that in this case.
Comment 6•11 years ago
|
||
Can someone provide a few hints about how to fix this? It's pretty annoying for us, and I might be able to hack on it.
Updated•11 years ago
|
(In reply to Dirkjan Ochtman (:djc) from comment #6) > Can someone provide a few hints about how to fix this? It's pretty annoying > for us, and I might be able to hack on it. You probably want to skip sending a message to the console if the result code EventSource::OnStopRequest gets is NS_BINDING_ABORTED.
Comment 8•11 years ago
|
||
In particular, I'd also want to not fire the EventSource error event.
Reporter | ||
Comment 9•11 years ago
|
||
Also, please note that as of (at least) FireFox 22.0, this same error is now showing up for WebSocket. Not sure if it's the same fix, but both EventSource and WebSocket should not throw a console error on page refresh. I think the request to also not fire the "error" event should be fixed as well.
Comment hidden (mozreview-request) |
Updated•6 years ago
|
Assignee | ||
Updated•5 years ago
|
Comment 11•2 years ago
|
||
For those that need it a work around I'm using is to close the eventSource before the page closes.
const eventSource = new EventSource('/api/v1/firehose');
window.addEventListener('beforeunload', () => {
eventSource.close();
});
Issue is still present in Firefox 95.0.2 (64-bit)
Updated•2 years ago
|
Comment 12•1 year ago
|
||
Without the
window.addEventListener("beforeunload", handleClose);
i get the following error:
Firefox can’t establish a connection to the server at http://localhost:3001/v1/stream/events.
when i add the "beforeunload", i still get an error, but a different one:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3001/v1/stream/events. (Reason: CORS request did not succeed). Status code: (null).
Does anyone else have the same problem?
(This is not a general CORS problem. The connection is established without further problems. It is exclusively about the reload).
Comment 13•1 year ago
|
||
(In reply to Fynn from comment #12)
Without the
window.addEventListener("beforeunload", handleClose);
i get the following error:
Firefox can’t establish a connection to the server at http://localhost:3001/v1/stream/events.
when i add the "beforeunload", i still get an error, but a different one:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3001/v1/stream/events. (Reason: CORS request did not succeed). Status code: (null).
Does anyone else have the same problem?
(This is not a general CORS problem. The connection is established without further problems. It is exclusively about the reload).
Description
•