Closed EmilJunker closed 8 months ago
@EmilJunker Did you find any workaround? facing the same issue
@Sarvesh-SP The only workaround I found so far is the one I mentioned above. Call the close()
method in a setTimeout
so it happens a bit later (one second seems to be enough).
Consider the following example:
The
httpstat.us/404
endpoint always returns a 404 error status. Since I callsse.close()
in the error handler, I would expect the SSE connection be closed pretty much immediately after it is created. However, this is not the case. If I run the above code, the SSE keeps trying to reconnect every 10 seconds . Apparently, callingsse.close()
does not properly stop the pollingInterval. Here are the logs I get when running the above code (it keeps repeating every 10 seconds):If I change the error handler to only close the SSE after waiting one second (using
setTimeout
), then it works:The 404 error is yielded twice for some reason, but this time closing the connection works:
In my opinion, this is a pretty serious bug. The SSE should always stop all its activity when the
close()
method is called. It certainly shouldn't try to auto-reconnect after this method was called.