Skip to content

Commit

Permalink
[fix] Trigger xhr polling transport unload handler on 'pagehide' or '…
Browse files Browse the repository at this point in the history
…unload' instead of 'beforeunload' (#604)

...to prevent broke connection on cancelled beforeunload event

Fixes #603
  • Loading branch information
SQReder authored and darrachequesne committed Nov 19, 2018
1 parent 484e3ec commit f62fca4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/transports/polling-xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
addEventListener(terminationEvent, unloadHandler, false);
}
}

Expand Down

0 comments on commit f62fca4

Please sign in to comment.