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
{{ message }}
Repository navigation
sockets can be undestroyed, confusing documentation #57367
How often does it reproduce? Is there a required condition?
Reliably. Whether a socket is destroyed by manually calling destroy() or by an error (e.g. ECONNRESET).
What is the expected behavior? Why is that the expected behavior?
The expected behavior is that a socket which is destroyed never can be opened again. This is expected because the documentation says that "no further data can be transferred" after a stream is destroyed, and because both Readable and Writable draw a distinction between the "closed" and "destroyed" properties.
socket.destroy:
Ensures that no more I/O activity happens on this socket. Destroys the stream and closes the connection.
socket.destroyed:
Indicates if the connection is destroyed or not. Once a connection is destroyed no further data can be transferred using it.
What do you see instead?
The socket can be reopened after it is destroyed. The above code prints "socket connected!" twice.
Additional information
I think we're likely stuck with the current behavior, but it should be very prominently documented.
I think this also breaks the semantics of Symbol.asyncDispose, as inherited from the Duplex interface.
changed the title [-]`socket.destroyed` returns true on a merely disconnected socket[/-][+]sockets can be undestroyed, confusing documentation[/+]on Mar 7, 2025
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.
This issue has been marked as stale due to 90 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.
Activity
[-]`socket.destroyed` returns true on a merely disconnected socket[/-][+]sockets can be undestroyed, confusing documentation[/+]github-actions commentedon Apr 20, 2026
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.
rotu commentedon Apr 20, 2026
unstale
github-actions commentedon Jul 20, 2026
This issue has been marked as stale due to 90 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.
rotu commentedon Jul 20, 2026
unstale
doc: clarify socket destroyed behavior
doc: clarify socket destroyed behavior
doc: clarify socket destroyed behavior
doc: clarify socket destroyed behavior
doc: clarify socket destroyed behavior
doc: clarify socket destroyed behavior