Skip to content

More explanation of autoUnref option in 4.0 client #4288

Answered by darrachequesne
qiulang asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! Setting autoUnref to true will allow the program to exit, even if the socket is currently connected.

const socket = io({
  autoUnref: true
});

setTimeout(() => {
  // program will now exit
}, 1000);

Without it, you will indeed need to call socket.disconnect().

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@qiulang
Comment options

@darrachequesne
Comment options

@qiulang
Comment options

@qiulang
Comment options

@qiulang
Comment options

Answer selected by qiulang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants