mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
stream: sync stream unpipe resume
pipe() ondata should not control flow state if cleaned up. Fixes: https://github.com/nodejs/node/issues/31190 PR-URL: https://github.com/nodejs/node/pull/31191 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
f62fb7603a
commit
256289fe83
2 files changed
+21
-1
No files matched your search
@@ -740,6 +740,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
|
||||
@@ -749,7 +750,6 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
|
||||
ondrain = pipeOnDrain(src, dest);
|
||||
dest.on('drain', ondrain);
|
||||
}
|
||||
src.pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const stream = require('stream');
|
||||
const fs = require('fs');
|
||||
|
||||
const readStream = fs.createReadStream(process.execPath);
|
||||
|
||||
const transformStream = new stream.Transform({
|
||||
transform: common.mustCall(() => {
|
||||
readStream.unpipe();
|
||||
readStream.resume();
|
||||
})
|
||||
});
|
||||
|
||||
readStream.on('end', common.mustCall());
|
||||
|
||||
readStream
|
||||
.pipe(transformStream)
|
||||
.resume();
|
||||
Reference in new issue
Block a user