Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify when readable._read(...) is called. #38726

Closed
wants to merge 1 commit into from

Conversation

sploders101
Copy link
Contributor

Fixes: #38586

This PR clarifies some confusion with the readable._read(...) function dealing with when it is called. The current version of the documentation seems to suggest that _read() is responsible for looping itself to continually request data until this.push(...) returns false, but this is not the case. After implementing a readable stream this way, I quickly found memory leaks in my code, because Node.JS was calling my _read function after every this.push(...), but I was also looping inside _read, resulting in an exponentially increasing number of reads on the remote resource. Hopefully this will help to clarify this behavior.

This is my first PR against NodeJS, so please let me know if there's anything I could do better.

@github-actions github-actions bot added doc Issues and PRs related to the documentations. stream Issues and PRs related to the stream subsystem. labels May 18, 2021
@ronag ronag requested a review from mcollina May 19, 2021 15:29
Copy link
Member

@mcollina mcollina left a comment

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
Collaborator

Comment on lines +2517 to +2518
called again after it has stopped should it resume pushing additional data into
the queue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change onto the queueinto the queue intentional? I noticed that into the read queue was used above, on line 2512, even before this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not intentional, but I think accomplishes the same goal. I tried to reword the existing paragraph, but it always seemed confusing and contradictory, so I ended up just rewriting it. I think into makes more sense though. I'd only use onto if I were saying I'm pushing onto *the end of* the queue.

@Ayase-252 Ayase-252 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 3, 2021
aduh95 pushed a commit that referenced this pull request Jun 3, 2021
Fixes: #38586

PR-URL: #38726
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
@aduh95
Copy link
Contributor

aduh95 commented Jun 3, 2021

Landed in 7f742ae

@aduh95 aduh95 closed this Jun 3, 2021
targos pushed a commit that referenced this pull request Jun 11, 2021
Fixes: #38586

PR-URL: #38726
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
@danielleadams danielleadams mentioned this pull request Jun 14, 2021
richardlau pushed a commit that referenced this pull request Jul 16, 2021
Fixes: #38586

PR-URL: #38726
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
richardlau pushed a commit that referenced this pull request Jul 19, 2021
Fixes: #38586

PR-URL: #38726
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
richardlau pushed a commit that referenced this pull request Jul 20, 2021
Fixes: #38586

PR-URL: #38726
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
@richardlau richardlau mentioned this pull request Jul 20, 2021
foxxyz pushed a commit to foxxyz/node that referenced this pull request Oct 18, 2021
Fixes: nodejs#38586

PR-URL: nodejs#38726
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

doc: Unclear relationship between _read and stream.push return value
8 participants