From 9b9762ccecee4e68376038d6eb6b1341511f3c39 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 18 Oct 2016 22:30:03 +0200 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/9553 PR-URL: https://github.com/nodejs/node/pull/9171 Fixes: https://github.com/nodejs/node/issues/9170 Reviewed-By: Evan Lucas Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Matteo Collina Reviewed-By: Myles Borins --- lib/_stream_readable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 92a1f6ad1ed52d..afa92f1d8cc907 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -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];