Skip to content

http: fix http client leaky with double response - #60062

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
theanarkh:fix_http_client_leaky
Oct 13, 2025
Merged

http: fix http client leaky with double response#60062
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
theanarkh:fix_http_client_leaky

Conversation

@theanarkh

Copy link
Copy Markdown
Contributor

Fixed: #60025

When a request corresponds to multiple responses, ensure that only the first one is processed and skip all subsequent invalid responses (or emit a response event then emit an error event on request object ?).

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-botnodejs-github-bot added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Sep 28, 2025
@codecov

codecovBot commented Sep 28, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.56%. Comparing base (db0121b) to head (88c0254).
⚠️ Report is 28 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #60062 +/- ##
==========================================
+ Coverage 88.53% 88.56% +0.02% 
==========================================
Files 704 704 Lines 208087 208097 +10 Branches 40010 40009 -1 ==========================================
+ Hits 184239 184297 +58 + Misses 15866 15816 -50 - Partials 7982 7984 +2 
Files with missing linesCoverage Δ
lib/_http_client.js97.35% <100.00%> (+0.02%)⬆️
lib/_http_common.js100.00% <100.00%> (ø)

... and 39 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pimterrypimterry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor point, otherwise LGTM.


or emit a response event then emit an error event on request object ?

Emitting an error here would be a breaking change that will probably break things for some people in real cases. Without that, I don't think this is semver-major, since other than the leak the 2nd response doesn't seem to have been observable until now.

I think emitting an error would probably still be best, because it is an error case where something's clearly gone wrong, and this matches our docs, which say

If any error is encountered during the request (be that with DNS resolution, TCP level errors, or actual HTTP parse errors) an 'error' event is emitted on the returned request object

but that said, it might be better to separate the two issues.

How about we aim to ship this to resolve the leak, and then ship a separate semver-major PR making this into an emitted request error in future?

Comment threadlib/_http_client.js Outdated
@theanarkh
theanarkhforce-pushed the fix_http_client_leaky branch 3 times, most recently from 552bafc to 6d9bd7dCompareOctober 9, 2025 15:40
@pimterrypimterry added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Oct 9, 2025
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 9, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment threadtest/parallel/test-http-client-leaky-with-double-response.js Outdated
Comment threadtest/parallel/test-http-client-leaky-with-double-response.js Outdated
@theanarkh
theanarkhforce-pushed the fix_http_client_leaky branch from 05e92b6 to 88c0254CompareOctober 11, 2025 13:56

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollinamcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 11, 2025
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 11, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@theanarkhtheanarkh added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 13, 2025
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 13, 2025
@nodejs-github-bot
nodejs-github-bot merged commit 59b70e5 into nodejs:mainOct 13, 2025
60 of 62 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 59b70e5

@RafaelGSSRafaelGSS mentioned this pull request Oct 13, 2025
9 tasks
aduh95 pushed a commit that referenced this pull request Oct 31, 2025
PR-URL: #60062Fixes: #60025
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
aduh95 pushed a commit that referenced this pull request Nov 7, 2025
PR-URL: #60062Fixes: #60025
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
aduh95 pushed a commit that referenced this pull request Feb 17, 2026
PR-URL: #60062Fixes: #60025
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@aduh95aduh95 mentioned this pull request Feb 22, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.httpIssues or PRs related to the http subsystem.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTPParser enters invalid state and keep ClientRequest in heap creating memory leak

5 participants

@theanarkh@nodejs-github-bot@mcollina@pimterry@marco-ippolito