Repository navigation
Conversation
forEach is implemented on top of readable.map. With the default concurrency of 1, chunks are processed strictly one at a time: the next chunk is not read until the previous fn call has settled, so the method only processes chunks concurrently when concurrency is greater than 1. Document this so users do not expect concurrent processing with the default options. Fixes: nodejs#66106 Signed-off-by: Ultroncn <82553854+Ultroncn@users.noreply.github.com>
Contributor
|
Caution AgentScan found account activity patterns that may be consistent with automation. This is a heuristic, not proof that this pull request was opened by an agent or violates policy. AI-assisted contributions are permitted, but automated tooling must not open pull requests without advance approval, and contributors must personally understand, test, verify, and take responsibility for every submitted change. See the AgentScan analysis, AI use policy, and automation policy for additional context. |
Describe callback sequencing without making assumptions about stream buffering. Assisted-by: Codex Signed-off-by: Ultroncn <82553854+Ultroncn@users.noreply.github.com>
Contributor
Author
|
Thanks for catching this. On Node.js v24.18.0, two more chunks were already buffered while the first callback was pending. I’ve updated the paragraph to describe when |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #66106
Hi! The
readable.forEach()docs say the method "can optionally process chunks concurrently", but with the defaultconcurrencyof1that does not happen:forEachis implemented on top ofreadable.map(lib/internal/streams/operators.js), and the map pump pauses reading until the previousfnpromise has settled, so chunks are processed strictly one at a time unlessconcurrencyis set above1.This PR clarifies that in the docs:
concurrencyis greater than1;Docs-only change, no code or tests affected. I checked the implementation and the existing
test-stream-forEach.jstests before writing this; happy to adjust the wording if reviewers prefer a different phrasing.