I started doing some debugging to nail down a situation that causes our users to stop receiving server sent events after they have the browser open for a long time. I was able to fix the issue but I noticed that the onException
handler in the ServerEventsClient was not being called after the client was initially disconnected for some reason, like when the user’s computer goes to sleep, wakes back up, and then tries to reconnect again after their session needs to be refreshed. I think I may have narrowed it down to this line of code in the client itself.
index.ts, line 386
const es = this.EventSource
? new this.EventSource(url, this.getEventSourceOptions())
: new EventSource(url, this.getEventSourceOptions());
es.addEventListener('error', e => opt.onerror || hold.onerror || this.onError);
es.addEventListener('message', opt.onmessage || hold.onmessage || this.onMessage);
I think the error handler is being set to a function that returns the callback that is supposed to be called instead of the callback itself. Shouldn’t the handler be attached the same way it is for the message
event? Should I put up a PR for this kind of thing?
Thanks
AJ