Skip to content

Commit

Permalink
streams: fix regression in unpipe()
Browse files Browse the repository at this point in the history
Since 2e568d9 there is a bug where unpiping a stream
from a readable stream that has `_readableState.pipesCount > 1`
will cause it to remove the first stream in the
`_.readableState.pipes` array no matter where in the list the
`dest` stream was.

This patch corrects that problem.

Fixes: #9170
  • Loading branch information
addaleax committed Oct 18, 2016
1 parent 0e6750d commit 431638d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ Readable.prototype.unpipe = function(dest) {
if (index === -1)
return this;

state.pipes.splice(i, 1);
state.pipes.splice(index, 1);
state.pipesCount -= 1;
if (state.pipesCount === 1)
state.pipes = state.pipes[0];
Expand Down

0 comments on commit 431638d

Please sign in to comment.