René's URL Explorer Experiment


Title: http: Agent with keepAlive and no timeout ignores the server's Keep-Alive timeout hint · Issue #66734 · nodejs/node · GitHub

Open Graph Title: http: Agent with keepAlive and no timeout ignores the server's Keep-Alive timeout hint · Issue #66734 · nodejs/node

X Title: http: Agent with keepAlive and no timeout ignores the server's Keep-Alive timeout hint · Issue #66734 · nodejs/node

Description: Version v24.18.0. The same code is on main (lib/_http_agent.js, Agent.prototype.keepSocketAlive). Platform Linux 6.18 x86_64 (WSL2); also seen in GitHub Actions containers on Ubuntu 24.04. Subsystem http What steps will reproduce the bug...

Open Graph Description: Version v24.18.0. The same code is on main (lib/_http_agent.js, Agent.prototype.keepSocketAlive). Platform Linux 6.18 x86_64 (WSL2); also seen in GitHub Actions containers on Ubuntu 24.04. Subsyste...

X Description: Version v24.18.0. The same code is on main (lib/_http_agent.js, Agent.prototype.keepSocketAlive). Platform Linux 6.18 x86_64 (WSL2); also seen in GitHub Actions containers on Ubuntu 24.04. Subsyste...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"http: Agent with keepAlive and no timeout ignores the server's Keep-Alive timeout hint","articleBody":"### Version\n\nv24.18.0. The same code is on `main` (`lib/_http_agent.js`, `Agent.prototype.keepSocketAlive`).\n\n### Platform\n\nLinux 6.18 x86_64 (WSL2); also seen in GitHub Actions containers on Ubuntu 24.04.\n\n### Subsystem\n\nhttp\n\n### What steps will reproduce the bug?\n\n```js\nconst http = require(\"node:http\");\n\nconst server = http.createServer((req, res) => res.end(\"ok\"));\nserver.keepAliveTimeout = 2000; // sends `Keep-Alive: timeout=2`\n\nfunction get(agent, port) {\n  return new Promise((resolve) => {\n    const req = http.get({ host: \"127.0.0.1\", port, agent }, (res) => {\n      res.resume();\n      res.on(\"end\", () => resolve({ hint: res.headers[\"keep-alive\"], reused: req.reusedSocket }));\n    });\n  });\n}\n\nserver.listen(0, \"127.0.0.1\", async () => {\n  const { port } = server.address();\n  for (const options of [{ keepAlive: true }, { keepAlive: true, timeout: 60_000 }]) {\n    const agent = new http.Agent(options);\n    const first = await get(agent, port);\n    await new Promise((r) => setTimeout(r, 1500)); // past hint - agentKeepAliveTimeoutBuffer (1000 ms)\n    const second = await get(agent, port);\n    console.log(JSON.stringify(options), \"hint:\", first.hint, \"-> second request reused the socket:\", second.reused);\n    agent.destroy();\n  }\n  server.closeAllConnections();\n  server.close();\n});\n```\n\n### How often does it reproduce? Is there a required condition?\n\nEvery time. The condition is an `http.Agent` with `keepAlive: true` and no `timeout` option.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n```\n{\"keepAlive\":true} hint: timeout=2 -> second request reused the socket: false\n{\"keepAlive\":true,\"timeout\":60000} hint: timeout=2 -> second request reused the socket: false\n```\n\nThe agent should retire a pooled socket at the server's `Keep-Alive: timeout=N` hint minus `agentKeepAliveTimeoutBuffer`, whether or not the agent has a timeout of its own. The comment in `keepSocketAlive` says the hint is applied to \"reduce the likelihood of ECONNRESET errors\". An agent with no timeout keeps sockets the longest, so it is the one that needs it most.\n\n### What do you see instead?\n\n```\n{\"keepAlive\":true} hint: timeout=2 -> second request reused the socket: true\n{\"keepAlive\":true,\"timeout\":60000} hint: timeout=2 -> second request reused the socket: false\n```\n\nWith no agent timeout, the hint is ignored:\n\n```js\nlet agentTimeout = this.options.timeout || 0;\n...\n} else if (serverHintTimeout \u003c agentTimeout) {\n  agentTimeout = serverHintTimeout;\n}\n```\n\nWhen `agentTimeout` is `0`, meaning no timeout, `serverHintTimeout \u003c agentTimeout` is never true. So the socket gets no timeout and stays pooled until the server closes it. A request that reuses it at that moment fails with `ECONNRESET`.\n\n### Additional information\n\nWe hit this through Playwright, whose API client is `new http.Agent({ keepAlive: true })` with no timeout. Its requests failed intermittently with `read ECONNRESET` against a Node 24 server (`keepAliveTimeout` 5000). The failing request reused a socket that had been idle 5.9 s, against a hint of 5 s.\n\nA possible fix is to treat `agentTimeout === 0` as \"no limit\":\n\n```js\n} else if (agentTimeout === 0 || serverHintTimeout \u003c agentTimeout) {\n```\n\nRelated, but a different case: #52649 (the race just before the server's timeout).\n","author":{"url":"https://github.com/xantius","@type":"Person","name":"xantius"},"datePublished":"2026-10-14T15:40:30Z","url":"https://github.com/nodejs/node/issues/66734"}

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:8cc2997f-5218-2ee6-c761-a7266f2cdd5d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDFD4:2356C0:6E5A9B:93507E:6B062CF5
html-safe-nonce9c8879bdb40bf25e1d242f065f42cbe9f595cdf92f2b20b644b2e5d86095c3c4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkQ0OjIzNTZDMDo2RTVBOUI6OTM1MDdFOjZCMDYyQ0Y1IiwidmlzaXRvcl9pZCI6Ijg2Mzg1NjY2ODQ1ODE4MzM5NzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac5093f8cc0fb46ea3f64cbf369d556d9b7e80d50e67002715a159dbf912d2c992
hovercard-subject-tagissue:5850795966
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/66734/issue_layout
twitter:imagehttps://opengraph.githubassets.com/bd591cb9d8777a399795d38b54fc4d07f6490218502db17704acaa9f59fddd31/nodejs/node/issues/66734
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/bd591cb9d8777a399795d38b54fc4d07f6490218502db17704acaa9f59fddd31/nodejs/node/issues/66734
og:image:altVersion v24.18.0. The same code is on main (lib/_http_agent.js, Agent.prototype.keepSocketAlive). Platform Linux 6.18 x86_64 (WSL2); also seen in GitHub Actions containers on Ubuntu 24.04. Subsyste...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamexantius
hostnamegithub.com
expected-hostnamegithub.com
None7f961de5dd5c5d4aca24d33f8b3ffb3fb8b2ef53d0a4f32f01f0a790e512f6d3
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
release494ea0bb1e0feef734a83e2628697647755e8864
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66734#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66734
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%2F66734
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/66734
Reloadhttps://github.com/nodejs/node/issues/66734
Reloadhttps://github.com/nodejs/node/issues/66734
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues630 (630)https://github.com/nodejs/node/issues
Pull requests660 (660)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/insights
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66734
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66734
#66779https://github.com/nodejs/node/pull/66779
http: Agent with keepAlive and no timeout ignores the server's Keep-Alive timeout hinthttps://github.com/nodejs/node/issues/66734#top
#66779https://github.com/nodejs/node/pull/66779
https://github.com/xantius
xantiushttps://github.com/xantius
on Oct 14, 2026https://github.com/nodejs/node/issues/66734#issue-5850795966
#52649https://github.com/nodejs/node/issues/52649
DivyanshuX9https://github.com/DivyanshuX9
on Oct 14, 2026https://github.com/nodejs/node/issues/66734#event-33256180203
http: respect Keep-Alive timeout hint when agent has no explicit timeouthttps://github.com/DivyanshuX9/node/commit/cc13d6538136a8761c9478de4dbc604da12bb50e
cc13d65https://github.com/DivyanshuX9/node/commit/cc13d6538136a8761c9478de4dbc604da12bb50e
test: add regression test for http agent Keep-Alive server hinthttps://github.com/DivyanshuX9/node/commit/5a3ecad28507b308728932ce7965ca6ba2390497
5a3ecadhttps://github.com/DivyanshuX9/node/commit/5a3ecad28507b308728932ce7965ca6ba2390497
test: fix http agent keep-alive server hint test case 4https://github.com/DivyanshuX9/node/commit/ef5f42f4b0fa4b9aaa665baed7658f0bae6d4e32
ef5f42fhttps://github.com/DivyanshuX9/node/commit/ef5f42f4b0fa4b9aaa665baed7658f0bae6d4e32
https://github.com/DivyanshuX9
DivyanshuX9https://github.com/DivyanshuX9
on Oct 14, 2026https://github.com/nodejs/node/issues/66734#issuecomment-6178195146
DivyanshuX9https://github.com/DivyanshuX9
on Oct 16, 2026https://github.com/nodejs/node/issues/66734#event-33405214433
http: respect Keep-Alive timeout hint when agent has no explicit timeouthttps://github.com/DivyanshuX9/node/commit/a12dfcb619a65d51ee38ccd6e53983d261b22b6e
a12dfcbhttps://github.com/DivyanshuX9/node/commit/a12dfcb619a65d51ee38ccd6e53983d261b22b6e
https://github.com/gustavovalverde
gustavovalverdehttps://github.com/gustavovalverde
on Nov 9, 2026https://github.com/nodejs/node/issues/66734#issuecomment-6744156278
microsoft/playwright#44007https://github.com/microsoft/playwright/issues/44007
#66779https://github.com/nodejs/node/pull/66779
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66734
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66734
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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.