René's URL Explorer Experiment


Title: http2: a destroyed `Http2Session` keeps its idle timer armed, so every closed session stays in memory until the server timeout fires · Issue #66885 · nodejs/node · GitHub

Open Graph Title: http2: a destroyed `Http2Session` keeps its idle timer armed, so every closed session stays in memory until the server timeout fires · Issue #66885 · nodejs/node

X Title: http2: a destroyed `Http2Session` keeps its idle timer armed, so every closed session stays in memory until the server timeout fires · Issue #66885 · nodejs/node

Description: Version v22.23.1, v24.21.0, v26.11.1 (and main: the code path below is unchanged) Platform Darwin 24.6.0 arm64 (macOS); the faulty logic is in lib/, not platform-specific Subsystem http2 What steps will reproduce the bug? // Run with: no...

Open Graph Description: Version v22.23.1, v24.21.0, v26.11.1 (and main: the code path below is unchanged) Platform Darwin 24.6.0 arm64 (macOS); the faulty logic is in lib/, not platform-specific Subsystem http2 What steps...

X Description: Version v22.23.1, v24.21.0, v26.11.1 (and main: the code path below is unchanged) Platform Darwin 24.6.0 arm64 (macOS); the faulty logic is in lib/, not platform-specific Subsystem http2 What steps...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"http2: a destroyed `Http2Session` keeps its idle timer armed, so every closed session stays in memory until the server timeout fires","articleBody":"### Version\n\nv22.23.1, v24.21.0, v26.11.1 (and `main`: the code path below is unchanged)\n\n### Platform\n\n```text\nDarwin 24.6.0 arm64 (macOS); the faulty logic is in lib/, not platform-specific\n```\n\n### Subsystem\n\nhttp2\n\n### What steps will reproduce the bug?\n\n```js\n// Run with: node --expose-gc repro.mjs\nimport http2 from \"node:http2\";\n\nconst TIMEOUT = 30_000;\nconst server = http2.createServer();\nserver.setTimeout(TIMEOUT, () => {});\nserver.on(\"request\", (_req, res) => res.end(\"ok\"));\nlet last;\nserver.on(\"session\", (s) => (last = s));\nawait new Promise((r) => server.listen(0, \"127.0.0.1\", r));\nconst url = `http://127.0.0.1:${server.address().port}`;\n\nasync function oneSession() {\n  const client = http2.connect(url);\n  await new Promise((r) => client.request({ \":path\": \"/\" }).resume().on(\"end\", r).end());\n  await new Promise((r) => client.close(r));\n  await new Promise((r) => setImmediate(r));\n}\n\n// 1. The session is destroyed, but its timeout was never cleared.\nawait oneSession();\nconsole.log(\"destroyed:\", last.destroyed, \"| timeout still armed:\", last.timeout); // true | 30000 (expected 0)\n\n// 2. Each closed session stays reachable until the timer fires.\nconst heap = () => (globalThis.gc(), globalThis.gc(), process.memoryUsage().heapUsed);\nfor (let i = 0; i \u003c 500; i++) await oneSession(); // warm up\nconst before = heap();\nfor (let i = 0; i \u003c 2000; i++) await oneSession();\nconsole.log(\"retained per closed session:\", ((heap() - before) / 2000 / 1024).toFixed(2), \"KiB\");\nserver.close();\n```\n\n\n### How often does it reproduce? Is there a required condition?\n\nAlways, as soon as the server has a session timeout (`server.setTimeout(ms)`, or `timeout` in the server options). Same result over TLS (`createSecureServer`).\n\n### What is the expected behavior? Why is that the expected behavior?\n\n```text\ndestroyed: true | timeout still armed: 0\nretained per closed session: ~0.00 KiB\n```\n\n`closeSession()` explicitly tries to do this — `// Clear timeout and remove timeout listeners.` — so a destroyed session should no longer be referenced by a timer.\n\n### What do you see instead?\n\n```text\nv26.11.1  destroyed: true | timeout still armed: 30000   retained per closed session: 1.77 KiB\nv24.21.0  destroyed: true | timeout still armed: 30000   retained per closed session: 1.80 KiB\nv22.23.1  destroyed: true | timeout still armed: 30000   retained per closed session: 2.47 KiB\n```\n\nThe retention is bounded by the timeout: with a 1 s timeout and a 1.5 s wait before measuring, it drops to 0. But under a steady flow of new connections it amounts to *new sessions/s × timeout × ~2 KiB* held at all times (e.g. 1,000 sessions/s with a 30 s timeout ≈ 60 MB).\n\n### Additional information\n\nThe cause is an ordering issue in `closeSession()` (`lib/internal/http2/core.js`):\n\n```js\nfunction closeSession(session, code, error) {\n  ...\n  state.flags |= SESSION_FLAGS_DESTROYED;   // (1) the session is now `destroyed`\n  state.destroyCode = code;\n\n  // Clear timeout and remove timeout listeners.\n  session.setTimeout(0);                     // (2) no-op\n  session.removeAllListeners('timeout');\n```\n\n`Http2Session.prototype.setTimeout` is `setStreamTimeout` (`lib/internal/stream_base_commons.js`), whose first statement is:\n\n```js\nfunction setStreamTimeout(msecs, callback) {\n  if (this.destroyed)\n    return this;\n```\n\nSo (2) returns immediately: `clearTimeout(this[kTimeout])` is never reached, and the `Timeout` (whose callback is bound to the session) keeps the whole session — socket, handle, buffers — reachable until it fires. `sessionOnTimeout` then returns early on `this.destroyed`, so the only visible effect is the memory.\n\n`Http2Stream` is not affected: after a stream closes, `stream.timeout` is `0` as expected.\n\nA possible fix is to clear the timer before setting `SESSION_FLAGS_DESTROYED` (or to call `clearTimeout(session[kTimeout])` directly in `closeSession`).\n\nUserland workaround: clear the timer while the session is still alive, e.g. on GOAWAY:\n\n```js\nserver.on(\"session\", (session) => {\n  session.once(\"goaway\", () => session.setTimeout(0));\n});\n```\n\nIt covers graceful closes (clients send GOAWAY on `close()` and `destroy()`), but not a TCP connection dropped without GOAWAY.\n","author":{"url":"https://github.com/ccamensuli","@type":"Person","name":"ccamensuli"},"datePublished":"2026-10-20T22:24:07Z","url":"https://github.com/nodejs/node/issues/66885"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:14c2f54e-4431-f197-180c-7fd7514ec55d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8E8E:30DACD:223A99:2DB35A:6AFBE268
html-safe-nonce30f94f70ed004c394b1f1e86c5ca9b3a67a43233516ef686a88a92649e6295c5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RThFOjMwREFDRDoyMjNBOTk6MkRCMzVBOjZBRkJFMjY4IiwidmlzaXRvcl9pZCI6IjU4OTQ5OTEyODA1MjcwMzg0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac7c8cc05874ff927c3fd2e10347d22eb34023ced2cbb1666b645e7e4040f8bf63
hovercard-subject-tagissue:5950639276
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/66885/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5981922eecd0ad7d2c98507c35a66903bcb5535f6fa03e6dcd9ece4455f3dd5d/nodejs/node/issues/66885
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5981922eecd0ad7d2c98507c35a66903bcb5535f6fa03e6dcd9ece4455f3dd5d/nodejs/node/issues/66885
og:image:altVersion v22.23.1, v24.21.0, v26.11.1 (and main: the code path below is unchanged) Platform Darwin 24.6.0 arm64 (macOS); the faulty logic is in lib/, not platform-specific Subsystem http2 What steps...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameccamensuli
hostnamegithub.com
expected-hostnamegithub.com
None744d4381b1c4dbd6d8736c7d7e5bbe7dc11217584e457a3555020c631764e8ec
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
releasedf859c48a4c8b4c0009c19bb4e82101aacb4b998
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66885#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66885
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%2F66885
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/66885
Reloadhttps://github.com/nodejs/node/issues/66885
Reloadhttps://github.com/nodejs/node/issues/66885
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues644 (644)https://github.com/nodejs/node/issues
Pull requests678 (678)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/66885
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66885
#66886https://github.com/nodejs/node/pull/66886
http2: a destroyed Http2Session keeps its idle timer armed, so every closed session stays in memory until the server timeout fireshttps://github.com/nodejs/node/issues/66885#top
#66886https://github.com/nodejs/node/pull/66886
https://github.com/ccamensuli
ccamensulihttps://github.com/ccamensuli
on Oct 20, 2026https://github.com/nodejs/node/issues/66885#issue-5950639276
ccamensulihttps://github.com/ccamensuli
on Oct 20, 2026https://github.com/nodejs/node/issues/66885#event-33791170436
docs(http): référencer nodejs/node#66885 sur le contournement du minu…https://github.com/nodefony/nodefony-core/commit/29f57fd06f70491d2330275dda750c3e97e0512d
nodejs/node#66885https://github.com/nodejs/node/issues/66885
29f57fdhttps://github.com/nodefony/nodefony-core/commit/29f57fd06f70491d2330275dda750c3e97e0512d
Huang-404-Qhttps://github.com/Huang-404-Q
on Oct 21, 2026https://github.com/nodejs/node/issues/66885#event-33811837919
http2: clear the session timeout before marking it destroyedhttps://github.com/Huang-404-Q/node/commit/cbc7a578cfe3e25f5eca927dcc6e5cbefaa1f47f
cbc7a57https://github.com/Huang-404-Q/node/commit/cbc7a578cfe3e25f5eca927dcc6e5cbefaa1f47f
http2: clear the session timeout before marking it destroyedhttps://github.com/Huang-404-Q/node/commit/24461fe07da8f6adb0de423b42cb6201a7521298
24461fehttps://github.com/Huang-404-Q/node/commit/24461fe07da8f6adb0de423b42cb6201a7521298
nodejs-github-bothttps://github.com/nodejs-github-bot
on Oct 28, 2026https://github.com/nodejs/node/issues/66885#event-34478735683
http2: clear the session timeout before marking it destroyedhttps://github.com/nodejs/node/commit/663f666fdaedb920d87371468324c909fee2cf2e
663f666https://github.com/nodejs/node/commit/663f666fdaedb920d87371468324c909fee2cf2e
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#66886https://github.com/nodejs/node/pull/66886
on Oct 28, 2026https://github.com/nodejs/node/issues/66885#event-34478736116
ccamensulihttps://github.com/ccamensuli
on Nov 11, 2026https://github.com/nodejs/node/issues/66885#event-35792300671
fix(http): fermer les connexions HTTP/2 inactives au-delà du délai (#763https://github.com/nodefony/nodefony-core/commit/df64ef1638528e31a3912496892b24a106b55faa
#763https://github.com/nodefony/nodefony-core/issues/763
df64ef1https://github.com/nodefony/nodefony-core/commit/df64ef1638528e31a3912496892b24a106b55faa
aduh95https://github.com/aduh95
on Nov 11, 2026https://github.com/nodejs/node/issues/66885#event-35823319564
http2: clear the session timeout before marking it destroyedhttps://github.com/nodejs/node/commit/0002058aa2a6d8936ba306609dd80ce4cbb0309a
0002058https://github.com/nodejs/node/commit/0002058aa2a6d8936ba306609dd80ce4cbb0309a
http2: clear the session timeout before marking it destroyedhttps://github.com/nodejs/node/commit/8d169a89ccba0982e92c48b7854fd266c0461c03
8d169a8https://github.com/nodejs/node/commit/8d169a89ccba0982e92c48b7854fd266c0461c03
ccamensulihttps://github.com/ccamensuli
on Nov 15, 2026https://github.com/nodejs/node/issues/66885#event-36195162109
feat(http): borner l'âge des connexions HTTP/2 et sonder les pairs muetshttps://github.com/nodefony/nodefony-core/commit/68d74ed3bbd69513bf7c18dbb89a4e4603f9c086
68d74edhttps://github.com/nodefony/nodefony-core/commit/68d74ed3bbd69513bf7c18dbb89a4e4603f9c086
test(http): prouver la gestion des connexions HTTP/2 sur le serveur réelhttps://github.com/nodefony/nodefony-core/commit/d895cfd43521894b5beb30362ce4ac417fdbefcd
d895cfdhttps://github.com/nodefony/nodefony-core/commit/d895cfd43521894b5beb30362ce4ac417fdbefcd
fix(http): ne plus perdre le GOAWAY d'un pair qui pingue trophttps://github.com/nodefony/nodefony-core/commit/299e1bb1de216dbc974ccca9064d13c23fc61af5
299e1bbhttps://github.com/nodefony/nodefony-core/commit/299e1bb1de216dbc974ccca9064d13c23fc61af5
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66885
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66885
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.