I noticed a strange issue whereby when refreshing a page with SSE on, the session count was increasing and the old sessions was remaining until cleanup occurred. On further investigation, it appears in Chrome that the $(window).on(“unload”) is not firing to unregister the event stream before reloading the page. It doesn’t occur even when moving to another site either.
It works fine with Firefox so I did a bit of research and people seem to state the onbeforeunload event works better than unload in Chrome.
Just wondered if you’d heard/seen this issue before?
I’ve found the information that relates to this issue:
Disallow Synchronous XMLHTTPRequest() in Page Dismissal
Chrome now disallows synchronous calls to XMLHTTPRequest() during page dismissal when the page is being navigated away from or is closed by the user. This applies to beforeunload , unload , pagehide , and visibilitychange .
To ensure that data is sent to the server when a page unloads, we recommend sendBeacon() or Fetchkeep-alive . For now, enterprise users can use the AllowSyncXHRInPageDismissal policy flag and developers can use the origin trial flag allow-sync-xhr-in-page-dismissal to allow synchronous XHR requests during page unload. This is a temporary “opt-out” measure, and we expect to remove this flag in Chrome 82.