Skip to content

Commit c25eb61

Browse files
addaleaxMyles Borins
authored andcommitted
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: nodejs#9553 PR-URL: nodejs#9171 Fixes: nodejs#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>
1 parent d7b9f36 commit c25eb61

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/_stream_readable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ Readable.prototype.unpipe = function(dest) {
664664
if (index === -1)
665665
return this;
666666

667-
state.pipes.splice(i, 1);
667+
state.pipes.splice(index, 1);
668668
state.pipesCount -= 1;
669669
if (state.pipesCount === 1)
670670
state.pipes = state.pipes[0];

0 commit comments

Comments
 (0)