Skip to content

stream: destroy half-open sockets after iteration - #65986

Open
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-stream-async-iterator-socket-leak
Open

stream: destroy half-open sockets after iteration#65986
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-stream-async-iterator-socket-leak

Conversation

@mcollina

Copy link
Copy Markdown
Member

Async iteration left the writable side of allowHalfOpen duplexes open after clean EOF. For net.Socket instances, this retained a live handle after the peer disconnected.

Restore default iterator destruction. Callers that need to continue writing can use iterator({ destroyOnReturn: false }).

Fixes: #65110

Async iteration left the writable side of `allowHalfOpen` duplexes open
after clean EOF. For `net.Socket` instances, this retained a live handle
after the peer disconnected.

Restore default iterator destruction. Callers that need to continue
writing can use `iterator({ destroyOnReturn: false })`.

Assisted-by: Codex
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@mcollina mcollina changed the title stream: destroy half-open sockets(parseló multicore?)/par: no stream: destroy half-open sockets Sep 11, 2026
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to Node.js streams. labels Sep 11, 2026
@mcollina
mcollina requested review from ronag and removed request for ronag September 11, 2026 15:37
@mcollina mcollina changed the title stream: destroy half-open sockets stream: destroy half-open sockets after iteration Sep 11, 2026
@mcollina

Copy link
Copy Markdown
Member Author

cc @trevnorris

@trevnorris

Copy link
Copy Markdown
Contributor

Excellent. Thank you!

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.16%. Comparing base (c909c63) to head (0539c7f).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65986      +/-   ##
==========================================
- Coverage   90.17%   90.16%   -0.01%     
==========================================
  Files         771      771              
  Lines      265451   265480      +29     
  Branches    50459    50454       -5     
==========================================
+ Hits       239361   239369       +8     
+ Misses      17059    17056       -3     
- Partials     9031     9055      +24     
Files with missing lines Coverage Δ
lib/internal/streams/readable.js 96.58% <100.00%> (-0.02%) ⬇️

... and 29 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. stream Issues and PRs related to Node.js streams.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple independent reports of out-of-memory crash after updating 24.18.1->24.19.0

5 participants