Skip to content

Commit f62fca4

Browse files
SQRederdarrachequesne
authored andcommitted
[fix] Trigger xhr polling transport unload handler on 'pagehide' or 'unload' instead of 'beforeunload' (#604)
...to prevent broke connection on cancelled beforeunload event Fixes #603
1 parent 484e3ec commit f62fca4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/transports/polling-xhr.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ if (typeof document !== 'undefined') {
401401
if (typeof attachEvent === 'function') {
402402
attachEvent('onunload', unloadHandler);
403403
} else if (typeof addEventListener === 'function') {
404-
addEventListener('beforeunload', unloadHandler, false);
404+
var terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
405+
addEventListener(terminationEvent, unloadHandler, false);
405406
}
406407
}
407408

0 commit comments

Comments
 (0)