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

stream: resume stream on drain #41848

Merged
merged 2 commits into from Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/internal/streams/readable.js
Expand Up @@ -853,8 +853,7 @@ function pipeOnDrain(src, dest) {

if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) &&
EE.listenerCount(src, 'data')) {
state.flowing = true;
flow(src);
src.resume();
}
};
}
Expand Down
17 changes: 17 additions & 0 deletions test/parallel/test-stream-readable-pause-and-resume.js
Expand Up @@ -56,3 +56,20 @@ function readAndPause() {
assert(readable.isPaused());
});
}

{
const { PassThrough } = require('stream');

const source3 = new PassThrough();
const target3 = new PassThrough();

const chunk = Buffer.allocUnsafe(1000);
let chunks = 1;
while (target3.write(chunk)) chunks++;

source3.pipe(target3);
target3.on('drain', common.mustCall(() => {
assert(!source3.isPaused());
}));
target3.on('data', () => {});
}