Skip to content

net: pending socket re-use #30832

Description

@ronag

It looks like net.Socket instances are intended to be re-used however while reading through the code I spot some potential problems:

  • _destroy(): doesn't wait for connect to finish
  • connect: doesn't first destroy if already connected, before connecting again
  • connect: doesn't wait for pending destroy to finish, before calling e.g. _undestroy()

Not sure if these are actual problems that need to be fixed?

@mcollina

Activity

  1. changed the title [-]net socket re-use[/-] [+]net: pending socket re-use[/+] on Dec 7, 2019
  2. mcollina commented on Dec 7, 2019

    @mcollina
    SponsorMember

    I think those things would ideally need to be fixed, however this is a really obscure feature of Node.js, and I suspect most do not even know that is there or why it's needed. If the fix are trivial, go for them. If they are complex, then it's probably not worth it.

  3. ronag commented on Dec 7, 2019

    @ronag
    MemberAuthor

    I'll look into it when porting it over to _construct.

    If they are complex, then it's probably not worth it.

    Would it be an option to hard deprecate re-use and error when trying to do so?

  4. mcollina commented on Dec 7, 2019

    @mcollina
    SponsorMember

    Would it be an option to hard deprecate re-use and error when trying to do so?

    Possibly, I'm not sure if there are some usage in the wild.

  5. added
    netIssues and PRs related to the net subsystem.
    on Dec 20, 2019
  6. ronag commented on Mar 10, 2020

    @ronag
    MemberAuthor

    I find connect w/ re-use kind of dangerous. Could we doc deprecate, add a runtime warning or something along those lines?

  7. github-actions commented on Jun 27, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 210 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  8. github-actions commented on Jul 28, 2026

    @github-actions
    Contributor

    This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
    If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

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

    netIssues and PRs related to the net subsystem.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions