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

Should not abort connections on beforeunload event #603

Closed
1 of 2 tasks
SQReder opened this issue Nov 9, 2018 · 3 comments
Closed
1 of 2 tasks

Should not abort connections on beforeunload event #603

SQReder opened this issue Nov 9, 2018 · 3 comments
Milestone

Comments

@SQReder
Copy link
Contributor

SQReder commented Nov 9, 2018

You want to:

  • report a bug
  • request a feature

Current behaviour

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

Setup

  • browser: Chrome
  • engine.io version: 1.1.0+

Other information

It should be replaced at least to unload or better pagehide event (which one is good supported - 93%)

We have had got very annoying floating bug with socket.io long-polling, which was stable reproduced with selenium tests in Chrome on Linux host, and all works well on windows host. Sometimes Chrome with no obvious reason want to freeze page, and so beforeunload triggered, so app is broken after that.

Here some related info:
Page lifecycle api:

PageTransitionEvent browsers support

@SQReder
Copy link
Contributor Author

SQReder commented Nov 9, 2018

Related to #406

@darrachequesne
Copy link
Member

I guess we could add something like:

if ('onpagehide' in window) {
   addEventListener('pagehide', unloadHandler, false);
} else {
   addEventListener('beforeunload', unloadHandler, false);
}

So as not to break 7% of the users. WDYT?

@SQReder
Copy link
Contributor Author

SQReder commented Nov 15, 2018

How about this one? It use pagehide when available, will correctly terminate connections on unload, and also not break things when beforeunload was cancelled.

var terminationEvent = 'onpagehide' in window ? 'pagehide' : 'unload';
addEventListener(terminationEvent, unloadHandler, false);

This issue was closed.
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

No branches or pull requests

2 participants