mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
stream: emit 'pause' on unpipe
unpipe should use pause() instead of mutating state.flowing directly so that pausing side effects such as emitting 'pause' are properly performed. Fixes: https://github.com/nodejs/node/issues/32470 PR-URL: https://github.com/nodejs/node/pull/32476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
b2e1a01516
commit
0d0f151a46
2 changed files with 12 additions and 2 deletions
|
@ -819,7 +819,7 @@ Readable.prototype.unpipe = function(dest) {
|
|||
// remove all.
|
||||
var dests = state.pipes;
|
||||
state.pipes = [];
|
||||
state.flowing = false;
|
||||
this.pause();
|
||||
|
||||
for (const dest of dests)
|
||||
dest.emit('unpipe', this, { hasUnpiped: false });
|
||||
|
@ -833,7 +833,7 @@ Readable.prototype.unpipe = function(dest) {
|
|||
|
||||
state.pipes.splice(index, 1);
|
||||
if (state.pipes.length === 0)
|
||||
state.flowing = false;
|
||||
this.pause();
|
||||
|
||||
dest.emit('unpipe', this, unpipeInfo);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue