profile
viewpoint

Ask questionsstream.finished behaviour change

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.

nodejs/node

Answer questions Fishrock123

The suggested fix is semver-minor, so reverting beforehand may still be desirable.

useful!

Related questions

Crash with "req.handle.writev is not a function" on Socket.Writable.uncork hot 2
--max-http-header-size= is not allowed in NODE_OPTIONS hot 2
Assertion `(parser->current_buffer_len_) == (0)' failed hot 1
pkg-exports: "." errors without a specified `main` hot 1
shutdown ENOTCONN on TLS.Socket._final hot 1
Node.js 12.10 throwing EPROTO on HTTPS request hot 1
Remove util.inherits usage internally? hot 1
[Bug] Node 10.1.0 TLS issue with ldap: Client network socket disconnected before secure TLS connection was established hot 1
ReferenceError: internalBinding is not defined hot 1
HTTP/2 requests eventually start throwing NGHTTP2_ENHANCE_YOUR_CALM errors hot 1
Incorrect timezone hot 1
HPE_INVALID_HEADER_TOKEN on http requests hot 1
HPE_INVALID_HEADER_TOKEN on http requests hot 1
crypto, bad decrypt hot 1
display node.js version (process.version) at the end of stacktraces hot 1
Github User Rank List