-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Closed
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
- Version: v7.2.1
- Platform: Arch linux 4.8.12-2 x86_64
- Subsystem: stream
const { Readable } = require("stream");
const readable = new Readable({
objectMode: true,
highWaterMark: 1,
read() {
push("inside call:");
},
});
const lines = [];
function push(w) {
while (lines.length) {
const state = readable._readableState;
console.log(w, "before push,", state.length, state.buffer.length, state.highWaterMark);
const ret = readable.push(lines.shift());
console.log(w, "after push,", "return:", ret, state.length, state.buffer.length, state.highWaterMark);
if (!ret) {
break;
}
}
}
setTimeout(() => {
lines.push("foo", "bar");
push("outside call:");
});
readable.on("data", function (data) {
readable.pause();
});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
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.