More explanation of autoUnref option in 4.0 client #4288
-
|
As explained here https://socket.io/docs/v3/migrating-from-3-x-to-4-0/#autounref-option, With But even in client 2.x if I close all the active sockets the program will exit, so what does these words "the Socket.IO client will allow the program to exit if there is no other active timer/socket in the event system" mean exactly ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
Hi! Setting const socket = io({
autoUnref: true
});
setTimeout(() => {
// program will now exit
}, 1000);Without it, you will indeed need to call |
Beta Was this translation helpful? Give feedback.
Hi! Setting
autoUnreftotruewill allow the program to exit, even if the socket is currently connected.Without it, you will indeed need to call
socket.disconnect().