Skip to content

Support unref method with option to autoUnref #653

Closed
@KCErb

Description

@KCErb

I'm opening this issue to discuss a PR I put up three weeks ago. Perhaps some community discussion is more appropriate/likely here than there?

Is your feature request related to a problem? Please describe.

If the close API isn't used, then the transport layer leaves some things around that will prevent the event loop from exiting. This is problematic when you are creating a library that uses socket.io under the hood and your user fails to let you know explicitly they are done messaging (something I'd really like to support, especially since it can be hard to find out why your program isn't exiting and hard to communicate that it might be because they failed to call close).

Describe the solution you'd like

I can understand why sometimes the desired behavior would be precisely to keep the program from exiting since you're not done with your socket io client! But in my case, it'd be great to have an option that is analogous to the unref API provided for timers, sockets, servers, and the like in core Node (links in the PR: #652)

Also, I ended up bumping into a related issue in the socket.io-client package and found it could use the same option to get the same effect: socketio/socket.io-client#1442.

Describe alternatives you've considered
I described some alternatives in a related issue on the socket.io-client repo: socketio/socket.io-client#1446. Basically it seems my only options are to either spawn a child process or just accept that the close method needs to be called.

Additional context
#652

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions