Skip to content

Commit

Permalink
fix(unload): use pagehide event instead of unload event
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Dec 16, 2023
1 parent b78cd12 commit a922c9f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/transports/sharedWorkerTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export abstract class SharedWorkerClientTransport<
listener,
sender,
});
window.addEventListener('unload', () => {
// do not use `unload` event
// https://developer.chrome.com/docs/web-platform/deprecating-unload
window.addEventListener('pagehide', () => {
// @ts-ignore
this.emit({ name: disconnectEventName, respond: false }, this.id);
});
Expand Down

0 comments on commit a922c9f

Please sign in to comment.