-
Notifications
You must be signed in to change notification settings - Fork 5
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
eventSource.onerror triggered before page reload #23
Comments
Hey @ivobelyasin thank you for the nice feedback! :) I am not sure if we could add the The first thing that comes to my mind is what happens if any other part of the app implements something like: window.onbeforeunload = (event) => {
const shouldBlockClose = ...
if(shouldBlockClose){
event.preventDefault();
}
}; and it I think we could evaluate the https://developer.chrome.com/docs/web-platform/page-lifecycle-api and maybe use |
Actually I can not reproduce it locally with a really simple app. eventsource/src/eventsource.ts Line 186 in daf7843
Would be happy if you could provide me with the error details @ivobelyasin :) |
Thank you for the quick reply @lukas-reining ! That's a very good point, listening to the onbeforeunload event opens possibilities for edge cases. I currently have this as error handler:
I just added the check for AbortError, however the error I get looks like this: The problem is that the browser doesn't allow me to expand it and see the details. I'm using the preserve log option but still...It seems like it's maybe not a proper error, as the name property is undefined if I try to log it. |
The problem is that the event source is not returning an So I think your check can not work. Have you enabled logging and see a warning log? I would expect it to be visible because of: eventsource/src/eventsource.ts Line 212 in daf7843
|
If you are getting |
Hey, a little comment, not very related to the problem described, but could be helpful anyway:
@apostrofix Do something like that: for (let key in e) {
console.log(key, e[key])
} It should preserve more visible data. Repeat this for nested objects if needed. |
Hello, first of all, thank you for providing this package! It works really well and it's easy to use!
I am just wondering, after a successful connection, if I reload the page, the
onerror
event gets triggered. I would like to have the listener for the error events so that I can send errors to my monitoring solutions, however this one doesn't exactly seem like an error but rather that the connection is just dropped by the browser probably (because of the page reload).As a workaround I added:
This works fine, however I am not the biggest fan of the
onbeforeunload
event and I am just wondering if that's the best approach. Did anybody else run into this scenario?The text was updated successfully, but these errors were encountered: