Some recent changes to stream.finished landed in Node master changes the behaviour of the function.
Before (in Node 12) if a stream was about to emit end/finish but hadn't and emitted close it would not be treated as an error. In master this triggers a premature close.
It's due to the changes here.
https://github.com/nodejs/node/blob/master/lib/internal/streams/end-of-stream.js#L86
This breaks modules that emit close immediately after calling stream.end() / push(null), for example the popular multistream module, https://github.com/feross/multistream.
A simple test case looks like this:
const Multistream = require('multistream')
const fs = require('fs')
const m = new Multistream([
fs.createReadStream(__filename)
])
m.resume()
stream.finished(m, function (err) {
console.log('should not error:', err)
})
We might want to revert those changes or at least document them.
Some recent changes to
stream.finishedlanded in Node master changes the behaviour of the function.Before (in Node 12) if a stream was about to emit end/finish but hadn't and emitted close it would not be treated as an error. In master this triggers a premature close.
It's due to the changes here.
https://github.com/nodejs/node/blob/master/lib/internal/streams/end-of-stream.js#L86
This breaks modules that emit
closeimmediately after calling stream.end() / push(null), for example the popular multistream module, https://github.com/feross/multistream.A simple test case looks like this:
We might want to revert those changes or at least document them.