Skip to content
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

Fix #603 Trigger xhr polling transport unload handler on pagehide or unload #604

Merged
merged 1 commit into from
Nov 19, 2018

Conversation

SQReder
Copy link
Contributor

@SQReder SQReder commented Nov 15, 2018

Instead of beforeunload to prevent broke connection on cancelled beforeunload event

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behaviour

Polling transport breaks every time after beforeunload triggered, even if page wasn't closed after event have have has handed.
See #603

New behaviour

Trigger xhr polling transport unload handler on pagehide or unload instead of beforeunload to prevent broke connection on cancelled beforeunload event.

…stead of beforeunload to prevent broke connection on cancelled beforeunload event
@@ -401,7 +401,8 @@ if (typeof document !== 'undefined') {
if (typeof attachEvent === 'function') {
attachEvent('onunload', unloadHandler);
} else if (typeof addEventListener === 'function') {
addEventListener('beforeunload', unloadHandler, false);
var terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
Copy link
Member

@darrachequesne darrachequesne Nov 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SQReder Could you please explain what motivates the change from beforeunload to unload?

Edit: oh ok, didn't see #603 (comment)

@darrachequesne darrachequesne merged commit f62fca4 into socketio:master Nov 19, 2018
@darrachequesne
Copy link
Member

Thanks! 👍

@darrachequesne darrachequesne added this to the 3.3.1 milestone Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants