From 8244efb904444aecefe957511d60454cbb1d9bc4 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. 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 9438bf92d3..0844604d96 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -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];