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