Title: net.connect options noDelay, keepAlive, keepAliveInitialDelay should be in the constructor instead · Issue #59823 · nodejs/node · GitHub
Open Graph Title: net.connect options noDelay, keepAlive, keepAliveInitialDelay should be in the constructor instead · Issue #59823 · nodejs/node
X Title: net.connect options noDelay, keepAlive, keepAliveInitialDelay should be in the constructor instead · Issue #59823 · nodejs/node
Description: Affected URL(s) https://nodejs.org/api/net.html Description of the problem The documentation for the connect method on net.Socket (https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) says that there are options noDelay,...
Open Graph Description: Affected URL(s) https://nodejs.org/api/net.html Description of the problem The documentation for the connect method on net.Socket (https://nodejs.org/api/net.html#socketconnectoptions-connectlisten...
X Description: Affected URL(s) https://nodejs.org/api/net.html Description of the problem The documentation for the connect method on net.Socket (https://nodejs.org/api/net.html#socketconnectoptions-connectlisten...
Opengraph URL: https://github.com/nodejs/node/issues/59823
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"net.connect options noDelay, keepAlive, keepAliveInitialDelay should be in the constructor instead","articleBody":"### Affected URL(s)\n\nhttps://nodejs.org/api/net.html\n\n### Description of the problem\n\nThe documentation for the `connect` method on `net.Socket` (https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) says that there are options `noDelay`, `keepAlive`, `keepAliveInitialDelay`. However, by looking at the source code, these options are in fact instead for the constructor of `new net.Socket`.\n\nTherefore, this code won't work (the last three options will be ignored):\n```js\nlet s = new net.Socket();\n\ns.connect({\n port: 80,\n host: \"[some host]\",\n noDelay: true,\n keepAlive: true,\n keepAliveInitialDelay: 60000});\n```\n\nMoving them to the options passed to the constructor instead will make it work.\n\nThis issue can easily be verified with `strace` on Linux.\n\nI suggest to fix the documentation to match the actual behaviour rather than changing the implementation to match the documentation. Looking at what options are available for the constructor vs. the connect method, it makes more sense to have these options in the constructor, since the connect method only have options regarding to the actual connection attempt (such as what host, port, ip family etc. to use for the connection attempt), while the socket constructor takes options to use for the socket itself, such as if half-open should be enabled etc.\n\nIt seems this issue has been present ever since these new options were added in https://github.com/nodejs/node/pull/41310. Note that if you use the `net.createConnection` factory method, you won't notice the issue since the same options are passed to both methods.","author":{"url":"https://github.com/Emill","@type":"Person","name":"Emill"},"datePublished":"2025-09-09T12:03:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/59823/node/issues/59823"}
| 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:667dbd9e-fd89-7861-3092-b11be52a0d67 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C736:3F81E9:E4D5A6:138C443:6A4C5F20 |
| html-safe-nonce | 9af32fd8abbfdb61e1b6cc659a51388947b2c8e6a241f32499175c279f7f7455 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzM2OjNGODFFOTpFNEQ1QTY6MTM4QzQ0Mzo2QTRDNUYyMCIsInZpc2l0b3JfaWQiOiIyNDUwMTU3NzU2MTM4NDEzODU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fa4a71d6111c447954dd1d2ae2700f9ceb596850cc62c3c262a7afd9a33f98df |
| hovercard-subject-tag | issue:3398116343 |
| 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/59823/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3ed73b5df0e7d7cee607822ec9dada91741af012eda041c189c68a094c6db4eb/nodejs/node/issues/59823 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3ed73b5df0e7d7cee607822ec9dada91741af012eda041c189c68a094c6db4eb/nodejs/node/issues/59823 |
| og:image:alt | Affected URL(s) https://nodejs.org/api/net.html Description of the problem The documentation for the connect method on net.Socket (https://nodejs.org/api/net.html#socketconnectoptions-connectlisten... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Emill |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| 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 | 14099438da5379150f15a2892474c7c7e6c0e55e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width