Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
stream: sync stream unpipe resume
pipe() ondata should not control flow state if cleaned up.

Fixes: #31190
  • Loading branch information
ronag committed Jan 5, 2020
commit ba3fe3ffe21df61b7fe2e7076fdf541eac765510
2 changes: 1 addition & 1 deletion lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
debug('false write response, pause', state.awaitDrainWriters.size);
state.awaitDrainWriters.add(dest);
}
src.pause();
}
if (!ondrain) {
// When the dest drains, it reduces the awaitDrain counter
Expand All @@ -748,7 +749,6 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
ondrain = pipeOnDrain(src, dest);
dest.on('drain', ondrain);
}
src.pause();
}
}

Expand Down
21 changes: 21 additions & 0 deletions test/parallel/test-stream-readable-unpipe-resume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const common = require('../common');

const stream = require('stream')

const fs = require('fs');
const readStream = fs.createReadStream('out/Release/node')
Comment thread
ronag marked this conversation as resolved.
Outdated

const transformStream = new class extends stream.Transform {
_transform() {
Comment thread
ronag marked this conversation as resolved.
Outdated
readStream.unpipe()
readStream.resume()
}
}

readStream.on('end', common.mustCall());

readStream
.pipe(transformStream)
.resume()