Title: sockets can be undestroyed, confusing documentation · Issue #57367 · nodejs/node · GitHub
Open Graph Title: sockets can be undestroyed, confusing documentation · Issue #57367 · nodejs/node
X Title: sockets can be undestroyed, confusing documentation · Issue #57367 · nodejs/node
Description: Version v22.14.0 Platform Microsoft Windows NT 10.0.26100.0 x64 Subsystem No response What steps will reproduce the bug? import net from 'node:net'; import { once } from 'node:events'; const sock = new net.Socket(); sock.on('connect', ()...
Open Graph Description: Version v22.14.0 Platform Microsoft Windows NT 10.0.26100.0 x64 Subsystem No response What steps will reproduce the bug? import net from 'node:net'; import { once } from 'node:events'; const sock =...
X Description: Version v22.14.0 Platform Microsoft Windows NT 10.0.26100.0 x64 Subsystem No response What steps will reproduce the bug? import net from 'node:net'; import { once } from 'node:events...
Opengraph URL: https://github.com/nodejs/node/issues/57367
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sockets can be undestroyed, confusing documentation","articleBody":"### Version\n\nv22.14.0\n\n### Platform\n\n```text\nMicrosoft Windows NT 10.0.26100.0 x64\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\n```js\nimport net from 'node:net';\nimport { once } from 'node:events';\n\nconst sock = new net.Socket();\nsock.on('connect', () => {\n console.log('socket connected!');\n});\n\nsock.connect({ host: 'example.com', port: '80' });\nawait once(sock, 'connect');\n\nsock.destroy();\n\nsock.connect({ host: 'example.com', port: '80' });\n```\n\n### How often does it reproduce? Is there a required condition?\n\nReliably. Whether a socket is destroyed by manually calling `destroy()` or by an error (e.g. ECONNRESET).\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe 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.\n\nsocket.destroy:\n> Ensures that no more I/O activity happens on this socket. Destroys the stream and closes the connection.\n\nsocket.destroyed:\n> Indicates if the connection is destroyed or not. Once a connection is destroyed no further data can be transferred using it.\n\n### What do you see instead?\n\nThe socket can be reopened after it is destroyed. The above code prints \"socket connected!\" twice.\n\n### Additional information\n\nI think we're likely stuck with the current behavior, but it should be *very* prominently documented.\n\nI think this also breaks the semantics of `Symbol.asyncDispose`, as inherited from the `Duplex` interface.","author":{"url":"https://github.com/rotu","@type":"Person","name":"rotu"},"datePublished":"2025-03-07T23:53:28Z","url":"https://github.com/nodejs/node/issues/57367"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:362695fd-3fbc-25a3-3105-920c7a887bb4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB00:2D1355:51DD3:7010C:6AED3AB2 |
| html-safe-nonce | c36bd4f142750806090bf02c055eb671670e218e0d616955f03b7cdac15af89f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjAwOjJEMTM1NTo1MUREMzo3MDEwQzo2QUVEM0FCMiIsInZpc2l0b3JfaWQiOiI4MTg2NzAwOTE5MTk0MDczNzc4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5e75429a33b7c2607ad8adccee8d9a5412d408660453f2b51352b31fa214ba6a |
| hovercard-subject-tag | issue:2904180115 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/57367/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1596e767b472d9ada7a0205ed3a8006ee54888330a60d49623e1e7574dab4581/nodejs/node/issues/57367 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1596e767b472d9ada7a0205ed3a8006ee54888330a60d49623e1e7574dab4581/nodejs/node/issues/57367 |
| og:image:alt | Version v22.14.0 Platform Microsoft Windows NT 10.0.26100.0 x64 Subsystem No response What steps will reproduce the bug? import net from 'node:net'; import { once } from 'node:events'; const sock =... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rotu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c629ad99c254d306375fc8354d04321c2c362236 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width