Skip to content

Commit

Permalink
fix: make closeOnBeforeunload default to false
Browse files Browse the repository at this point in the history
Silently closing the connection when receiving a "beforeunload" event
is problematic, because it is emitted:

- when downloading a file from another host

Related: socketio/socket.io#4436

- when the user already has a listener for the "beforeunload" event
(i.e. "are you sure you want to leave this page?")

Related:

- #661
- #658
- socketio/socket.io#4065

That's why the `closeOnBeforeunload` option will now default to false.
  • Loading branch information
darrachequesne committed Jun 28, 2023
1 parent 1fc61a3 commit a63066b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export interface SocketOptions {

/**
* Whether to automatically close the connection whenever the beforeunload event is received.
* @default true
* @default false
*/
closeOnBeforeunload: boolean;

Expand Down Expand Up @@ -347,7 +347,7 @@ export class Socket extends Emitter<
threshold: 1024,
},
transportOptions: {},
closeOnBeforeunload: true,
closeOnBeforeunload: false,
},
opts
);
Expand Down

0 comments on commit a63066b

Please sign in to comment.