Skip to content

Commit a63066b

Browse files
fix: make closeOnBeforeunload default to false
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.
1 parent 1fc61a3 commit a63066b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/socket.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export interface SocketOptions {
170170

171171
/**
172172
* Whether to automatically close the connection whenever the beforeunload event is received.
173-
* @default true
173+
* @default false
174174
*/
175175
closeOnBeforeunload: boolean;
176176

@@ -347,7 +347,7 @@ export class Socket extends Emitter<
347347
threshold: 1024,
348348
},
349349
transportOptions: {},
350-
closeOnBeforeunload: true,
350+
closeOnBeforeunload: false,
351351
},
352352
opts
353353
);

0 commit comments

Comments
 (0)