You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm opening this issue to discuss a PR I put up a couple of weeks ago. Perhaps some community discussion is more appropriate/likely here than there?
Is your feature request related to a problem? Please describe.
If a client app is trying to reconnect, it leaves a refd timer on the event loop which will prevent the program from exiting. This might be desirable behavior but it'd be nice to be able to turn it off.
Of course, the other alternative is to just use the close method, but I'm trying to handle gracefully the case where the user calling my library fails to call close on my wrapper and is scratching their head as to why their program is hung.
With autoUnref set to true (default: false), the Socket.IO client will
allow the program to exit if there is no other active timer/socket in
the event system.
```js
const socket = io({
autoUnref: true
});
```
Note: this option only applies to Node.js clients.
Related: #1446
With autoUnref set to true (default: false), the Socket.IO client will
allow the program to exit if there is no other active timer/socket in
the event system.
```js
const socket = io({
autoUnref: true
});
```
Note: this option only applies to Node.js clients.
Related: socketio/socket.io-client#1446
I'm opening this issue to discuss a PR I put up a couple of weeks ago. Perhaps some community discussion is more appropriate/likely here than there?
Is your feature request related to a problem? Please describe.
If a client app is trying to reconnect, it leaves a
ref
d timer on the event loop which will prevent the program from exiting. This might be desirable behavior but it'd be nice to be able to turn it off.Describe the solution you'd like
The timer API already supports the notion of
unref
for exactly this purpose: https://node.readthedocs.io/en/latest/api/timers/#unref. And I ran into a similar issue in the underlying engine so the two could share the same option: socketio/engine.io-client#652.Describe alternatives you've considered
One alternative I've considered came from this stackoverflow thread: https://stackoverflow.com/questions/62028744/can-socket-io-clients-be-setup-to-not-keep-nodejs-from-exiting to spawn a child. It's a bit awkward having to serialize and pass info from the child back to the parent via IPC though just to deal with socket.io internals preventing the event loop from exiting.
Of course, the other alternative is to just use the close method, but I'm trying to handle gracefully the case where the user calling my library fails to call
close
on my wrapper and is scratching their head as to why their program is hung.Additional context
#1442
The text was updated successfully, but these errors were encountered: