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
.close() gives exception #130
Comments
I cannot reproduce it, is there a way to setup a server and reproduce it? |
Hmm, shame. I can't copy my server side code here. |
I also get this when calling close() using version 1.0.5 and Chrome 74.0.3729.169 on Mac
The connection is closed, it just that it causes an exception. Seems like a client or browser issue, if this is a server issue, is there a sample server that works with this client such that close() does not cause an exception? What server was used for the development and testing of this client? |
@Yaffle I am able to reproduce the issue using the example server code in the Readme. I created a Node server using the example server js and used the index.html also as per the example. I had to modify the index.html to explicitly create an instance of EventSourcePolyfill instead of just EventSource as recent versions of chrome already include EventSource so the polyfill is not used. If the polyfill is not used, the close() exception does not occur. I just added a setTimeout to close the connection after 5 seconds and boom, the Dom exception occurs. Here is my modified index.html (i also modified the script path /src/eventsource.js in both the index.html and server.js to match my file structure)
|
ok, I was able to reproduce it, thank you.
|
Version 1.0.7 works great, thanks! |
Thank you for solving the issue! Greatly appreciated! |
For anyone interested, AbortError is still happening in Firefox, but imo it is now a Firefox issue. StackBlitz: https://stackblitz.com/edit/firefox-fetch-abort-error |
IMHO, it can be reproduced like this: var controller = new AbortController();
var signal = controller.signal;
fetch('data:text/plain,test', {signal}).then(function(response) {
const reader = response.body.getReader();
controller.abort();
//reader.cancel(); - this needs to be used to avoid the log message, seems
}).catch(function(e) {
console.log('catched', e);
}).finally(function(e) {
console.log('done');
}); |
@earshinov, a workaround was added, but it is still throws on the page unload |
@Yaffle , I guess all errors can be fixed by subscribing to the Promise returned from
After this change I cannot reproduce the AbortError in Firefox any longer. I updated my StackBlitz example: https://stackblitz.com/edit/firefox-fetch-abort-error |
Im trying to close my SSE connection but I get an exception.
I initiate like this:
this.source = new EventSourcePolyfill(url, { headers: { "X-Requested-With": "XMLHttpRequest" } });
And then I close it like this:
this.source.close();
I get the following exception:
Uncaught (in promise) DOMException
And Chrome tells me that the issue is on line 460:
reader.cancel();
The text was updated successfully, but these errors were encountered: