Skip to content

stream: change in stdout/stderr events from child process (missing finish) #19764

Description

@travisperson

I believe commit 9c0c0e68ac introduced a breaking change to what events are emitted from child process streams stdout/stderr.

const { spawn } = require('child_process')

const ps = spawn('ls', ['-al'])

ps.stdout.on('finish', function() {
  console.log('Called `finish` on stdout')
});

ps.stdout.on('end', function() {
  console.log('Called `end` on stdout')
});

ps.stderr.on('finish', function() {
  console.log('Called `finish` on stderr')
});

ps.stderr.on('end', function() {
  console.log('Called `end` on stderr')
});

In node v9.9.0

Called `end` on stderr
Called `end` on stdout

In node v9.8.0

Called `end` on stderr
Called `finish` on stderr
Called `end` on stdout
Called `finish` on stdout

Per the documentation, finish should only be associated with a writable stream, so the current behavior in 9.9.0 seems to be accurate. Given that, I'm not sure if the previous behavior was a bug or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.streamIssues and PRs related to Node.js streams.wontfixIssues that will not be fixed.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions