Skip to content

stream: avoid mutable push in consumers and operators - #67884

Open
rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:stream-private-arrays-no-push
Open

rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:stream-private-arrays-no-push

Conversation

@rozzilla

@rozzilla rozzilla commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

blob() in stream/consumers, the readable.map() queue and pipeline()'s destroy and cleanup lists used .push() on private arrays. This uses indexed assignments instead, as arrayBuffer() in stream/consumers already does.

Same approach as #67748, #67751 and #67752: private arrays only, no performance claim. readable.js state.buffer and state.pipes are left alone because they are reachable through _readableState.

The blob() consumer, the readable.map() queue, and pipeline()'s destroy
and cleanup lists collected values with .push() on private arrays, which
looks up Array.prototype.push at call time. Replacing that method from
user code changed how these operations ran. Use indexed assignments
instead, as arrayBuffer() in stream/consumers already does.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@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 Node.js streams. labels Nov 30, 2026
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.58%. Comparing base (1611823) to head (bdc8eaf).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #67884   +/-   ##
=======================================
  Coverage   90.58%   90.58%           
=======================================
  Files         802      802           
  Lines      286656   286656           
  Branches    55369    55370    +1     
=======================================
+ Hits       259668   259679   +11     
+ Misses      17089    17087    -2     
+ Partials     9899     9890    -9     
Files with missing lines Coverage Δ
lib/internal/streams/operators.js 96.10% <100.00%> (ø)
lib/internal/streams/pipeline.js 95.24% <100.00%> (ø)
lib/stream/consumers.js 99.35% <100.00%> (ø)

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

2 participants