René's URL Explorer Experiment


Title: tls: createSecureContext() drops options.singleUse, so per-connection contexts live until GC · Issue #66002 · nodejs/node · GitHub

Open Graph Title: tls: createSecureContext() drops options.singleUse, so per-connection contexts live until GC · Issue #66002 · nodejs/node

X Title: tls: createSecureContext() drops options.singleUse, so per-connection contexts live until GC · Issue #66002 · nodejs/node

Description: Version 22.23.2 Platform Amazon Linux 2023, x86_64 and aarch64 Subsystem No response What steps will reproduce the bug? Version v22.23.2 (verified at runtime); same code present in v24.18.0, v26.8.2, v26.x and main Platform Linux (Amazon...

Open Graph Description: Version 22.23.2 Platform Amazon Linux 2023, x86_64 and aarch64 Subsystem No response What steps will reproduce the bug? Version v22.23.2 (verified at runtime); same code present in v24.18.0, v26.8....

X Description: Version 22.23.2 Platform Amazon Linux 2023, x86_64 and aarch64 Subsystem No response What steps will reproduce the bug? Version v22.23.2 (verified at runtime); same code present in v24.18.0, v26.8....

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"tls: createSecureContext() drops options.singleUse, so per-connection contexts live until GC","articleBody":"### Version\n\n22.23.2\n\n### Platform\n\n```text\nAmazon Linux 2023, x86_64 and aarch64\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\n### Version\nv22.23.2 (verified at runtime); same code present in v24.18.0, v26.8.2, v26.x and main\n\n### Platform\nLinux (Amazon Linux 2023, x86_64 and aarch64), OpenSSL 3.5.7, glibc malloc — not platform specific\n\n### Subsystem\ntls\n\n### What steps will reproduce the bug?\n\n```js\nconst tls = require('node:tls');\n\nconst socket = tls.connect({ host: 'example.com', port: 443 }, () => {\n  console.log(socket.ssl._secureContext.singleUse); // undefined — expected true\n  socket.end();\n});\n```\n\n`tls.connect()` sets `options.singleUse = true` (lib/internal/tls/wrap.js), but the context\nit builds never carries the flag.\n\n### How often does it reproduce?\nAlways.\n\n### What is the expected behavior?\n\n`TLSSocket.prototype._destroySSL()` and `TLSWrap.prototype.close()` both check\n`ssl._secureContext.singleUse` and call `context.close()`, which frees the underlying\n`SSL_CTX` when the socket closes. Up to v15.14.0 `createSecureContext()` copied the flag\nonto the context it returned (lib/_tls_common.js):\n\n```js\n  if (options.singleUse) {\n    c.singleUse = true;\n    c.context.setFreeListLength(0);\n  }\n```\n\n### What do you see instead?\n\nSince v16.0.0, when context configuration moved into `configSecureContext()`, that copy was\ndropped. `singleUse` now appears only in `lib/internal/tls/wrap.js` — nothing assigns it to a\ncontext — so `ssl._secureContext.singleUse` is always `undefined`, `context.close()` is never\ncalled, and each connection's `SSL_CTX` lives until V8 collects the JS `SecureContext` wrapper.\n\nTwo things make that costly:\n\n* `SecureContext` reports `kExternalSize = 1024` bytes to V8 (src/crypto/crypto_context.h),\n  while an OpenSSL 3 `SSL_CTX` is roughly 16 KB — and far larger when `ca` is supplied, since\n  the context then holds its own parsed copy of the root store. V8 therefore sees almost no\n  reason to collect. (`TLSWrap` accounts ~50 KB but subtracts it in `Destroy()` at close, so\n  nothing remains on the books.)\n* In a process with a low allocation rate, major GCs can be more than an hour apart, so the\n  dead contexts accumulate for that whole period.\n\nMeasured with `malloc_stats()` before and after a forced full GC, after ~200 sequential\nclient connections (Node v22.23.2):\n\n| | in use after churn | after full GC | held per closed socket |\n|---|---|---|---|\n| as shipped (context per connection) | 7.24 MB | 4.09 MB | ~16 KB |\n| `createSecureContext` patched to copy `singleUse` | 3.99 MB | 3.99 MB | ~0 |\n| one shared `secureContext` passed to `tls.connect` | 3.99 MB | 3.98 MB | ~0 |\n\nProduction impact for us: a MongoDB connection pool recycling idle connections\n(`minPoolSize: 5`, `maxIdleTimeMS: 60000`, four worker threads) grew RSS ~4.5 MB per 10\nminutes with trust supplied through `NODE_EXTRA_CA_CERTS`, and ~113 MB per 10 minutes when\nthe CA bundle was passed as `tlsCAFile` — each connection's context then parses its own copy\nof the 96-certificate bundle. Passing one shared `secureContext` stops the growth entirely.\n\n### Additional note: the keepAlive condition\n\n`tls.connect()` only sets `singleUse` when `!options.keepAlive`. A client that enables TCP\nkeepalive (the MongoDB driver sets `keepAlive: true` unconditionally) therefore never gets the\nearly close even if the propagation is restored. Since the context is built per connection\neither way, and keepAlive concerns the TCP socket rather than the TLS context, should the\ncontext be closed on socket close regardless of that flag?\n\n### Possible fixes\n\n1. Restore the copy in `createSecureContext()` — one line.\n2. Report a realistic external size for `SecureContext` so V8 accounts for it.\n3. Reconsider the `keepAlive` condition, per the note above.\n\n### How often does it reproduce? Is there a required condition?\n\nevery time\n\n### What is the expected behavior? Why is that the expected behavior?\n\nto release memory\n\n### What do you see instead?\n\nmemory keep increasing\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/naturalfreak","@type":"Person","name":"naturalfreak"},"datePublished":"2026-09-12T15:58:24Z","url":"https://github.com/nodejs/node/issues/66002"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8f8c941c-da34-f18e-d143-06995a037a7f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA5A2:2C9BD4:A89C1:E88F7:6AED3348
html-safe-noncea37e066f858d4ac7c4d8a838e540b90d8dc9525e6151d6792ae61cf5267b7947
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUEyOjJDOUJENDpBODlDMTpFODhGNzo2QUVEMzM0OCIsInZpc2l0b3JfaWQiOiI4NjgwOTc1NzUwMDA2NjQ5NjcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac59ffa802c26c8a36d7387468eb08b2c0d57c3fb7965e552a46307b51e4858c4a
hovercard-subject-tagissue:5434388397
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/66002/issue_layout
twitter:imagehttps://opengraph.githubassets.com/76b5759e0d37e382194442d4358d37bbe4f4f5ce2a6183551d227c1b0af5ddfb/nodejs/node/issues/66002
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/76b5759e0d37e382194442d4358d37bbe4f4f5ce2a6183551d227c1b0af5ddfb/nodejs/node/issues/66002
og:image:altVersion 22.23.2 Platform Amazon Linux 2023, x86_64 and aarch64 Subsystem No response What steps will reproduce the bug? Version v22.23.2 (verified at runtime); same code present in v24.18.0, v26.8....
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenaturalfreak
hostnamegithub.com
expected-hostnamegithub.com
Nonee51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a
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
release59ebb7b901cc154ecc179a44f266fcf69f343b30
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66002#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66002
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66002
Sign uphttps://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/66002
Reloadhttps://github.com/nodejs/node/issues/66002
Reloadhttps://github.com/nodejs/node/issues/66002
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests665 (665)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66002
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66002
#66025https://github.com/nodejs/node/pull/66025
tls: createSecureContext() drops options.singleUse, so per-connection contexts live until GChttps://github.com/nodejs/node/issues/66002#top
#66025https://github.com/nodejs/node/pull/66025
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
memoryIssues and PRs related to Node.js memory management or memory footprint.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22memory%22
regressionIssues related to regressions.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22regression%22
tlsIssues and PRs related to the tls subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22tls%22
https://github.com/naturalfreak
naturalfreakhttps://github.com/naturalfreak
on Sep 12, 2026https://github.com/nodejs/node/issues/66002#issue-5434388397
https://github.com/inoway46
inoway46https://github.com/inoway46
on Sep 14, 2026https://github.com/nodejs/node/issues/66002#issuecomment-5666278259
be819d5https://github.com/nodejs/node/commit/be819d54704642056ca1f4a672c0e056aecf42b4
#1522https://github.com/nodejs/node/issues/1522
#38116https://github.com/nodejs/node/pull/38116
inoway46https://github.com/inoway46
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
tlsIssues and PRs related to the tls subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22tls%22
memoryIssues and PRs related to Node.js memory management or memory footprint.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22memory%22
regressionIssues related to regressions.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22regression%22
on Sep 14, 2026https://github.com/nodejs/node/issues/66002#event-31110945208
https://github.com/ViniciusDev26
ViniciusDev26https://github.com/ViniciusDev26
on Sep 14, 2026https://github.com/nodejs/node/issues/66002#issuecomment-5669786884
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#66025https://github.com/nodejs/node/pull/66025
on Sep 17, 2026https://github.com/nodejs/node/issues/66002#event-31291825098
nodejs-github-bothttps://github.com/nodejs-github-bot
on Sep 17, 2026https://github.com/nodejs/node/issues/66002#event-31291825170
tls: propagate singleUse to the secure contexthttps://github.com/nodejs/node/commit/e204ae8ce527f434ae5fe84f5a2568e2ae19a749
e204ae8https://github.com/nodejs/node/commit/e204ae8ce527f434ae5fe84f5a2568e2ae19a749
pwassmhttps://github.com/pwassm
on Sep 17, 2026https://github.com/nodejs/node/issues/66002#event-31323052488
dev1003: proxy 0xC0000409 hunt - the Sept 16-17 silent deaths had 16G…https://github.com/pwassm/jjj/commit/92b3bfc8620064ca1a681f92b34f772cb972be8c
92b3bfchttps://github.com/pwassm/jjj/commit/92b3bfc8620064ca1a681f92b34f772cb972be8c
aduh95https://github.com/aduh95
on Sep 18, 2026https://github.com/nodejs/node/issues/66002#event-31401356525
tls: propagate singleUse to the secure contexthttps://github.com/nodejs/node/commit/02c2302c317403eca825984f40db0ccd9ebb23de
02c2302https://github.com/nodejs/node/commit/02c2302c317403eca825984f40db0ccd9ebb23de
tls: propagate singleUse to the secure contexthttps://github.com/nodejs/node/commit/e899d0e4853cf18877e7cb41ee6a843d61772c68
e899d0ehttps://github.com/nodejs/node/commit/e899d0e4853cf18877e7cb41ee6a843d61772c68
tls: propagate singleUse to the secure contexthttps://github.com/nodejs/node/commit/ec37f934db7a4023c6b3d7b04e3d15aa8e2c14d2
ec37f93https://github.com/nodejs/node/commit/ec37f934db7a4023c6b3d7b04e3d15aa8e2c14d2
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66002
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66002
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
memoryIssues and PRs related to Node.js memory management or memory footprint.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22memory%22
regressionIssues related to regressions.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22regression%22
tlsIssues and PRs related to the tls subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22tls%22
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.