-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
stream: readable.push returns true at internal buffer size equal highWaterMark #10214
Comments
/cc @nodejs/streams |
I think this is not a bug. If you see this code, https://github.com/nodejs/node/blob/master/lib/_stream_readable.js#L419-L424, another event is scheduled to happen in the future, and because of this Some questions: a. is this causing issues in real-world code? |
@mcollina function push(w) {
while (lines.length) {
const ret = readable.push(lines.shift());
if (!ret) {
input.pause();
return;
}
}
// if first readable.push returns false, the seconds call returns true,
// it will re-resume the paused input stream
if (lines.length === 0) {
input.resume();
}
}
const input = readline(); // readline returns a stream that reads line by line
input.on("data", (data) => {
lines.push(data);
}); |
@zbinlin I'm not 100% understanding the exact implication for this, and assessing the impact for the community and the ecosystem. Can you please upload the full example? It seems an endless loop from here, also that interaction between |
This issue has been inactive for sufficiently long that it seems like perhaps it should be closed. Feel free to re-open (or leave a comment requesting that it be re-opened) if you disagree. I'm just tidying up and not acting on a super-strong opinion or anything like that. |
On above testcase code, it will output:
outside call: before push, 0 0 1
inside call: before push, 0 0 1
inside call: after push, return: false 1 1 1
outside call: after push, return: true 1 1 1
expect output:
outside call: before push, 0 0 1
inside call: before push, 0 0 1
inside call: after push, return: false 1 1 1
outside call: after push, return: false 1 1 1
The text was updated successfully, but these errors were encountered: