Skip to content

'process.stdout cannot be closed': process.stdout should behave like a standard stream #7606

Closed
@yinrong

Description

@yinrong
  • Version: latest
  • Platform: all
  • Subsystem: node/lib/internal/process/stdio.js

sample code:

// hang process
setTimeout(function(){}, 9999999)
// in heavy development, there usually exists something that hangs the process.
// we use 'process.exit' to solve this quickly.

var stream = require('stream')
process.stdin
  .pipe(new stream.PassThrough()) // there can be a list of Transform
  .pipe(new stream.PassThrough()) // there can be a list of Transform
  .pipe(new stream.PassThrough()) // there can be a list of Transform
  .on('end', function() {
    // process.exit()
    // exit here will stop stdout from flushing
  })
  .pipe(process.stdout)
  .on('finish', function() {  // this event will not trigger
    process.exit()
  })

execution result: hangs forever

expect: process.stdout should behaves like a standard stream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    processIssues and PRs related to the process subsystem.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