Skip to content

add autoUnref option to Manager #1446

Closed
@KCErb

Description

@KCErb

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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions