Version
18.4.0
Platform
Linux & Microsoft Windows NT 10.0.19044.0 x64
Subsystem
stream
What steps will reproduce the bug?
const { pipeline, Duplex, PassThrough, finished } = require('stream')
const remote = new PassThrough()
const local = new Duplex({
read () {},
write (chunk, enc, callback) {
callback()
}
})
for (const event of ['close', 'finish', 'end']) {
remote.on(event, () => console.log('remote', event))
local.on(event, () => console.log('local', event))
}
pipeline(remote, local, remote, function () {
// We never get here
console.log('done')
})
// To fix, uncomment:
// finished(local, { writable: true, readable: false }, () => local.destroy())
setImmediate(() => {
remote.end()
})
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
remote end
remote finish
local finish
remote close
local close
done
Not necessarily in that order.
What do you see instead?
remote end
remote finish
local finish
remote close
Additional information
The writable side of the local Duplex stream finishes, but the readable side does not. I can see two arguments here, for deciding whether this is a bug in core.
- Because the
local stream has disconnected readable and writable sides, that stream is responsible for destroying itself and/or ending its readable side.
- On the other hand, the readable side of the
local stream is being piped to the now-closed remote stream, so it's a dead end. It'd be a different story for pipeline(x, local), i.e. local being the last stream, because then the pipeline isn't consuming the readable side of local. But in pipeline(x, local, x) I expect the pipeline to fully manage the lifetime of local.
Last version where it works is 12.22.9 (or readable-stream@3). On 14.0.0, 16.14.2, 18.4.0, or readable-stream@4, it does not.
Version
18.4.0
Platform
Linux & Microsoft Windows NT 10.0.19044.0 x64
Subsystem
stream
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
Not necessarily in that order.
What do you see instead?
Additional information
The writable side of the
localDuplex stream finishes, but the readable side does not. I can see two arguments here, for deciding whether this is a bug in core.localstream has disconnected readable and writable sides, that stream is responsible for destroying itself and/or ending its readable side.localstream is being piped to the now-closedremotestream, so it's a dead end. It'd be a different story forpipeline(x, local), i.e.localbeing the last stream, because then the pipeline isn't consuming the readable side oflocal. But inpipeline(x, local, x)I expect the pipeline to fully manage the lifetime oflocal.Last version where it works is 12.22.9 (or
readable-stream@3). On 14.0.0, 16.14.2, 18.4.0, orreadable-stream@4, it does not.