Closed
Description
- Version: 6.8.0 and later
- Platform: all
- Subsystem: stream.Readable
Since node 6.8.0 there is a bug where unpiping a stream from a readable stream that has a _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.
Example test case:
"use strict"
const PassThrough = require('stream').PassThrough
const source = PassThrough()
const dest1 = PassThrough()
const dest2 = PassThrough()
source.pipe(dest1)
source.pipe(dest2)
source.unpipe(dest2)
console.log(source._readableState.pipes === dest1) //false
console.log(source._readableState.pipes === dest2) //true
As you can see, the wrong stream was unpiped
It looks like this is the commit that broke things (2e568d9#diff-ba6a0df0f5212f5cba5ca5179e209a17R670)
The variable used to splice was renamed to index
on line 670, however the splice call on line 674 is still using the incorrect variable i
.