Skip to content

add autoUnref option to Manager #1446

Closed

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

Activity

  1. added
    enhancement
    on Feb 22, 2021
  2. added a commit that references this issue on Mar 10, 2021
  3. darrachequesne commented on Mar 12, 2021

    @darrachequesne
    Member

    Implemented in 6abfa1f and included in socket.io-client@4.0.0. Thanks!

  4. added this to the 4.0.0 milestone on Mar 12, 2021
  5. added a commit that references this issue on Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions