Skip to content

stream: readable read one buffer at a time - #60441

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
ronag:read-no-copy
Jan 21, 2026
Merged

stream: readable read one buffer at a time#60441
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
ronag:read-no-copy

Conversation

@ronag

@ronagronag commented Oct 27, 2025

Copy link
Copy Markdown
Member
Instead of wasting cycles concatenating buffers, just return each
one by one.
Similar (but not exact) old behavior can be achieved by using
`readable.read(readable.readableLength)` instead of
`readable.read()`. In some edge cases it might be necessary
to do a `readable.read(0)` first.

@ronag
ronag requested a review from mcollinaOctober 27, 2025 18:44
@nodejs-github-bot

nodejs-github-bot commented Oct 27, 2025

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels Oct 27, 2025
Comment threadtest/parallel/test-stream-readable-infinite-read.js Outdated

@mcollinamcollina left a comment

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.

code lgtm

I think some docs changes are needed

@mcollinamcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jan 2, 2026
@mcollina

Copy link
Copy Markdown
Member

Marked as semver-major.

@lpinca

lpinca commented Jan 2, 2026

Copy link
Copy Markdown
Member

I'm -1 on this unless there is a strong reason for it. Historically, readable.read() has always returned all queued data. If this lands, I think that the easiest workaround for modules affected by the breaking change would be replacing readable.read() with readable.read(readable.readableLength).

@ronag

ronag commented Jan 2, 2026

Copy link
Copy Markdown
MemberAuthor

I'm -1 on this unless there is a strong reason for it.

The performance overhead is huge. As it stand we should at least add a note to avoid this api for anything performance sensitive.

If this lands, I think that the easiest workaround for modules affected by the breaking change would be replacing readable.read() with readable.read(readable.readableLength).

Good point.

@ronag

ronag commented Jan 2, 2026

Copy link
Copy Markdown
MemberAuthor

I think some docs changes are needed

What doc changes are you roughly asking for?

@ronag
ronagforce-pushed the read-no-copy branch 2 times, most recently from a380c35 to 0798db8CompareJanuary 2, 2026 08:55
@ronag
ronag marked this pull request as ready for review January 2, 2026 08:56
@ronagronag added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 2, 2026
@github-actionsgithub-actionsBot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jan 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor
Failed to start CI
 ⚠ Commits were pushed since the last approving review:
⚠ - stream: readable read one buffer at a time
✘ Refusing to run CI on potentially unsafe PR
https://github.com/nodejs/node/actions/runs/20654449594

@ronagronag added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. labels Jan 2, 2026
@github-actionsgithub-actionsBot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jan 2, 2026

@mcollinamcollina left a comment

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.

lgtm

@ronagronag added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 5, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 5, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Instead of wasting cycles concatenating buffers, just return each
one by one.
Similar (but not exact) old behavior can be achieved by using
`readable.read(readable.readableLength)` instead of
`readable.read()`. In some edge cases it might be necessary
to do a `readable.read(0)` first.
PR: nodejs#60441
@ronag

ronag commented Jan 5, 2026

Copy link
Copy Markdown
MemberAuthor

@lpinca Do you need help fixing ws in relation to this PR or can you deal with it yourself?

@mcollinamcollina left a comment

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.

lgtm

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@lpinca

Copy link
Copy Markdown
Member

@lpinca Do you need help fixing ws in relation to this PR or can you deal with it yourself?

I've already fixed it in websockets/ws@1998485

@ronag

ronag commented Jan 5, 2026

Copy link
Copy Markdown
MemberAuthor

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ronagronag added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 6, 2026

@mcollinamcollina left a comment

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.

lgtm

@ronag
ronag requested review from jasnell and lpincaJanuary 6, 2026 18:34

@gurgundaygurgunday left a comment

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.

lgtm

@mcollinamcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 20, 2026
@nodejs-github-botnodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jan 20, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/60441
✔ Done loading data for nodejs/node/pull/60441
----------------------------------- PR info ------------------------------------
Title stream: readable read one buffer at a time (#60441)
Author Robert Nagy <ronagy@icloud.com> (@ronag)
Branch ronag:read-no-copy -> nodejs:main
Labels stream, semver-major, author ready, needs-ci, needs-citgm
Commits 1
- stream: readable read one buffer at a time
Committers 1
- Robert Nagy <ronagy@icloud.com>
PR-URL: https://github.com/nodejs/node/pull/60441
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/60441
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
--------------------------------------------------------------------------------
ℹ This PR was created on Mon, 27 Oct 2025 18:44:50 GMT
✔ Approvals: 3
✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/60441#pullrequestreview-3631894479
✔ - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/60441#pullrequestreview-3632251382
✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/60441#pullrequestreview-3635847744
✘ semver-major requires at least 2 TSC approvals
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2026-01-05T21:27:50Z: https://ci.nodejs.org/job/node-test-pull-request/70687/
ℹ Last CITGM CI on 2026-01-05T09:54:54Z: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/3663/
- Querying data for job/node-test-pull-request/70687/
✔ Build data downloaded
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/21187285768

@mcollina

Copy link
Copy Markdown
Member

@nodejs/tsc can I get another approval?

@mcollinamcollina added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jan 21, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in fadb214

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

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs that need a full CI run.needs-citgmPRs that need a CITGM CI run.semver-majorPRs that contain breaking changes and should be released in the next major version.streamIssues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@ronag@nodejs-github-bot@mcollina@lpinca@MattiasBuelens@anonrig@gurgunday