Skip to content

stream.finished behaviour change #29699

Closed
@mafintosh

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions