René's URL Explorer Experiment


Title: tls: `tls.connect()` silently ignores `keepAlive`, `keepAliveInitialDelay`, and `noDelay` options · Issue #62003 · nodejs/node · GitHub

Open Graph Title: tls: `tls.connect()` silently ignores `keepAlive`, `keepAliveInitialDelay`, and `noDelay` options · Issue #62003 · nodejs/node

X Title: tls: `tls.connect()` silently ignores `keepAlive`, `keepAliveInitialDelay`, and `noDelay` options · Issue #62003 · nodejs/node

Description: Version v24.1.0 (also affects main; present since at least v20.x) Platform Darwin arm64 (but the platform is irrelevant to the issue) Subsystem tls What steps will reproduce the bug? Run the following script and observe difference betwee...

Open Graph Description: Version v24.1.0 (also affects main; present since at least v20.x) Platform Darwin arm64 (but the platform is irrelevant to the issue) Subsystem tls What steps will reproduce the bug? Run the follow...

X Description: Version v24.1.0 (also affects main; present since at least v20.x) Platform Darwin arm64 (but the platform is irrelevant to the issue) Subsystem tls What steps will reproduce the bug? Run the follow...

Opengraph URL: https://github.com/nodejs/node/issues/62003

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"tls: `tls.connect()` silently ignores `keepAlive`, `keepAliveInitialDelay`, and `noDelay` options","articleBody":"### Version\n\nv24.1.0 (also affects main; present since at least v20.x)\n\n### Platform\n\n```text\nDarwin arm64 (but the platform is irrelevant to the issue)\n```\n\n### Subsystem\n\ntls\n\n### What steps will reproduce the bug?\n\nRun the following script and observe difference between `net.connect()` and `tls.connect()` keepAlive options:\n\n```js\nnet.connect() - socket[kSetNoDelay]: true\nnet.connect() - socket[kSetKeepAlive]: true\nnet.connect() - socket[kSetKeepAliveInitialDelay]: 5\ntls.connect() - socket[kSetNoDelay]: false\ntls.connect() - socket[kSetKeepAlive]: false\ntls.connect() - socket[kSetKeepAliveInitialDelay]: 0\n```\n\n```js\nimport tls from \"node:tls\";\nimport net from \"node:net\";\nimport assert from \"node:assert\";\nimport { execSync } from \"node:child_process\";\nimport fs from \"node:fs\";\n\nexecSync(\n  'openssl req -new -x509 -newkey rsa:2048 -nodes -keyout /tmp/k.pem -out /tmp/c.pem -days 1 -subj \"/CN=localhost\" 2\u003e/dev/null',\n);\n\nconst tmp = new net.Socket();\nconst syms = Object.getOwnPropertySymbols(tmp);\nconst kSetNoDelay = syms.find((s) =\u003e s.toString() === \"Symbol(kSetNoDelay)\");\nconst kSetKeepAlive = syms.find(\n  (s) =\u003e s.toString() === \"Symbol(kSetKeepAlive)\",\n);\nconst kSetKeepAliveInitialDelay = syms.find(\n  (s) =\u003e s.toString() === \"Symbol(kSetKeepAliveInitialDelay)\",\n);\ntmp.destroy();\n\nconst opts = { keepAlive: true, keepAliveInitialDelay: 5000, noDelay: true };\n\nconst netServer = net.createServer((s) =\u003e s.end());\nnetServer.listen(0, () =\u003e {\n  const socket = net.connect({ port: netServer.address().port, ...opts });\n  socket.on(\"connect\", () =\u003e {\n    console.log(\"net.connect() - socket[kSetNoDelay]:\", socket[kSetNoDelay]); // true\n    console.log(\n      \"net.connect() - socket[kSetKeepAlive]:\",\n      socket[kSetKeepAlive], // true\n    );\n    console.log(\n      \"net.connect() - socket[kSetKeepAliveInitialDelay]:\",\n      socket[kSetKeepAliveInitialDelay],  // 5s\n    );\n    socket.destroy();\n    netServer.close();\n    testTls();\n  });\n});\n\nfunction testTls() {\n  const srv = tls.createServer(\n    {\n      key: fs.readFileSync(\"/tmp/k.pem\"),\n      cert: fs.readFileSync(\"/tmp/c.pem\"),\n    },\n    (s) =\u003e s.end(),\n  );\n  srv.listen(0, () =\u003e {\n    const socket = tls.connect({\n      port: srv.address().port,\n      rejectUnauthorized: false,\n      ...opts,\n    });\n    socket.on(\"secureConnect\", () =\u003e {\n      console.log(\"tls.connect() - socket[kSetNoDelay]:\", socket[kSetNoDelay]); // false\n      console.log(\n        \"tls.connect() - socket[kSetKeepAlive]:\",\n        socket[kSetKeepAlive], // false\n      );\n      console.log(\n        \"tls.connect() - socket[kSetKeepAliveInitialDelay]:\",\n        socket[kSetKeepAliveInitialDelay], // 0\n      );\n      socket.destroy();\n      srv.close();\n    });\n  });\n}\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways. Any call to `tls.connect()` with `keepAlive`, `keepAliveInitialDelay`, or `noDelay` options will silently ignore them.\n\nLong-lived TLS connections through infrastructure with idle timeouts (load balancers, NAT gateways, firewalls, AWS PrivateLink) silently break when `keepalive` is not applied. The connection is closed by an intermediary during an idle period, and the response never reaches the client. This is difficult to diagnose because `tls.connect()` accepts the options without error.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`tls.connect()` should honor `keepAlive`, `keepAliveInitialDelay`, and `noDelay` options, applying them to the underlying TCP socket (i.e., `setsockopt(SO_KEEPALIVE)`  / `setsockopt(TCP_NODELAY)` should be called).\n\nThe [documentation](https://nodejs.org/docs/latest/api/tls.html#tlsconnectoptions-callback) states that `tls.connect()` accepts:\n```\n...: Any socket.connect() option not already listed.\n```\n\n`socket.connect()` documents `keepAlive`, `keepAliveInitialDelay`, and `noDelay` as supported options. `net.createConnection()` with the same options works correctly.\n\n### What do you see instead?\n\nThe options are silently dropped. `setsockopt(SO_KEEPALIVE)` is never called on the underlying socket.\n\n### Additional information\n\nThe options are lost at two filtering points in `lib/internal/tls/wrap.js`:\n\n1. `tls.connect() → new TLSSocket()` ([lines 1743-1758](https://github.com/nodejs/node/blob/main/lib/internal/tls/wrap.js#L1743-L1758))\n\n`tls.connect()` constructs a `TLSSocket` with a hardcoded subset of options. `keepAlive`, `keepAliveInitialDelay`, and `noDelay` are not included:\n\n```js\nconst tlssock = new TLSSocket(options.socket, {\n  allowHalfOpen: options.allowHalfOpen,\n  pipe: !!options.path,\n  secureContext: context,\n  isServer: false,\n  requestCert: true,\n  rejectUnauthorized: options.rejectUnauthorized !== false,\n  session: options.session,\n  ALPNProtocols: options.ALPNProtocols,\n  requestOCSP: options.requestOCSP,\n  enableTrace: options.enableTrace,\n  pskCallback: options.pskCallback,\n  highWaterMark: options.highWaterMark,\n  onread: options.onread,\n  signal: options.signal,\n  // keepAlive, keepAliveInitialDelay, noDelay not forwarded\n});\n```\nNote: `keepAlive` is read at [line 1727](https://github.com/nodejs/node/blob/main/lib/internal/tls/wrap.js#L1727), but only to set `singleUse` - it is not forwarded to the socket layer.\n\n2. `TLSSocket constructor → net.Socket` super call ([lines 585-593](https://github.com/nodejs/node/blob/main/lib/internal/tls/wrap.js#L585-L593))\n\nEven if the options were forwarded to `TLSSocket`, the `net.Socket` super-constructor call also uses a hardcoded subset that omits them:\n\n```js\nFunctionPrototypeCall(net.Socket, this, {\n  handle: ...,\n  allowHalfOpen: ...,\n  pauseOnCreate: tlsOptions.pauseOnConnect,\n  manualStart: true,\n  highWaterMark: tlsOptions.highWaterMark,\n  onread: !socket ? tlsOptions.onread : null,\n  signal: tlsOptions.signal,\n  // keepAlive, keepAliveInitialDelay, noDelay not forwarded\n});\n```\n\nThe `net.Socket` constructor ([lib/net.js:475-476](https://github.com/nodejs/node/blob/main/lib/net.js#L475-L476)) sets `kSetNoDelay`, `kSetKeepAlive`, and `kSetKeepAliveInitialDelay` from the options, and these are later applied in `afterConnect()`. Since the options are never passed through, the symbols remain `false/0`.\n\n```js\nthis[kSetNoDelay] = Boolean(options.noDelay);\nthis[kSetKeepAlive] = Boolean(options.keepAlive);\n```\n\nAt the same time `net.createConnection()` works: `net.connect()` creates `new Socket(options)` with the **full** options object, so the constructor picks up all three options and stores them as symbols that `afterConnect` applies.\n\nFix: Both filtering points need to forward `keepAlive`, `keepAliveInitialDelay`, and `noDelay`.","author":{"url":"https://github.com/tadjik1","@type":"Person","name":"tadjik1"},"datePublished":"2026-02-26T10:07:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/62003/node/issues/62003"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:219089ce-d56d-0de0-ff97-8848ad8c6b5a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8792:30A7B5:56EF21:77D442:6A4C8801
html-safe-nonceed133046e0e759fb216478a355e57fd9ab82bff9c3e7909cb9ff70c5462ba7d5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzkyOjMwQTdCNTo1NkVGMjE6NzdENDQyOjZBNEM4ODAxIiwidmlzaXRvcl9pZCI6IjY4MzIyMjI2MzM4MDQ0NjYxNzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac186e9e3a846807d7ebd04570d122cbc521eaa72258e656f5eea9b63fb6f74f9f
hovercard-subject-tagissue:3994560853
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/62003/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a99223e284dc65b11708d0a9a787fbcc96469ed2ec44d9b9a9fdbe329f21911b/nodejs/node/issues/62003
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a99223e284dc65b11708d0a9a787fbcc96469ed2ec44d9b9a9fdbe329f21911b/nodejs/node/issues/62003
og:image:altVersion v24.1.0 (also affects main; present since at least v20.x) Platform Darwin arm64 (but the platform is irrelevant to the issue) Subsystem tls What steps will reproduce the bug? Run the follow...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametadjik1
hostnamegithub.com
expected-hostnamegithub.com
None3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7a2dede45637df6b92ddcfe2a557e67d4b5854ae
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/issues/62003#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F62003
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F62003
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/62003
Reloadhttps://github.com/nodejs/node/issues/62003
Reloadhttps://github.com/nodejs/node/issues/62003
Please reload this pagehttps://github.com/nodejs/node/issues/62003
nodejs https://github.com/nodejs
nodehttps://github.com/nodejs/node
Please reload this pagehttps://github.com/nodejs/node/issues/62003
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode
Fork 36k https://github.com/login?return_to=%2Fnodejs%2Fnode
Star 118k https://github.com/login?return_to=%2Fnodejs%2Fnode
Code https://github.com/nodejs/node
Issues 1.4k https://github.com/nodejs/node/issues
Pull requests 964 https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality 0 https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
Code https://github.com/nodejs/node
Issues https://github.com/nodejs/node/issues
Pull requests https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
#62004https://github.com/nodejs/node/pull/62004
tls: tls.connect() silently ignores keepAlive, keepAliveInitialDelay, and noDelay optionshttps://github.com/nodejs/node/issues/62003#top
#62004https://github.com/nodejs/node/pull/62004
https://github.com/tadjik1
tadjik1https://github.com/tadjik1
on Feb 26, 2026https://github.com/nodejs/node/issues/62003#issue-3994560853
documentationhttps://nodejs.org/docs/latest/api/tls.html#tlsconnectoptions-callback
lines 1743-1758https://github.com/nodejs/node/blob/main/lib/internal/tls/wrap.js#L1743-L1758
line 1727https://github.com/nodejs/node/blob/main/lib/internal/tls/wrap.js#L1727
lines 585-593https://github.com/nodejs/node/blob/main/lib/internal/tls/wrap.js#L585-L593
lib/net.js:475-476https://github.com/nodejs/node/blob/main/lib/net.js#L475-L476
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.