Skip to content

stream: destroy source when map iterator closes early#64264

Open
Y1D7NG wants to merge 1 commit into
nodejs:mainfrom
Y1D7NG:fix-stream-find-some-every-destroy
Open

stream: destroy source when map iterator closes early#64264
Y1D7NG wants to merge 1 commit into
nodejs:mainfrom
Y1D7NG:fix-stream-find-some-every-destroy

Conversation

@Y1D7NG

@Y1D7NG Y1D7NG commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes: #64261

When some(), every(), or find() returns early, the underlying map() iterator closes but the source stream is never destroyed, leaving it open and preventing cleanup. The fix calls destroyImpl.destroyer(stream, null) in the map() iterator cleanup path so the source stream is destroyed when the iterator closes early.

Fixes: nodejs#64261
Signed-off-by: y1d7ng <y1d7ng@yeah.net>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels Jul 2, 2026
@Y1D7NG

Y1D7NG commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@jasnell Could you please help review this? Thanks!

@trivikr trivikr requested a review from jasnell July 9, 2026 05:53
resume();
resume = null;
}
destroyImpl.destroyer(stream, null);

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.

Is an abrupt destroy the right thing here? Or should it be a natural close? @ronag @mcollina ... I'm legitimately not sure which is most correct here.

@ronag ronag added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 9, 2026
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. semver-major PRs that contain breaking changes and should be released in the next major version. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

readable.find()/some()/every() don't destroy the stream on match when the source hasn't ended

5 participants