Permalink
Browse files

streams: fix regression in `unpipe()`

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.

Ref: #9553
PR-URL: #9171
Fixes: #9170
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
  • Loading branch information...
addaleax authored and MylesBorins committed Oct 18, 2016
1 parent 4238460 commit 9b9762ccecee4e68376038d6eb6b1341511f3c39
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/_stream_readable.js
View
@@ -664,7 +664,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];

0 comments on commit 9b9762c

Please sign in to comment.