Skip to content

process.stdout/.stderr might loose data when calling process.exit() #3669

Closed
@minesworld

Description

@minesworld

this won't work reliable (but it should according to the docs):

  var empty = new Buffer(0)
  process.stdout.write(empty, function() { 
    process.stderr.write(empty, function() { 
       process.exit(code);
    });
  });

Not all data is flushed when node.js ends and thus another process using its output will not get all written data.

It also doesn't help to use something like

stream.pipe(process.stdout);
stream.push(null);

That .end() throws and an finish is never emitted makes using process.stdout/.stderr something like lottery.

Also trying to workaround via

fs.createWritableStream(null, {fd:1});

leads to another bunch of problems like EAGAIN errors.

I would suggest to implement .end() and finish events so that both process.stdout and .stderr behave like any other stream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.processIssues and PRs related to the process subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions