Skip to content

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

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.

Activity

  1. Fishrock123 commented on Nov 5, 2015

    @Fishrock123
    Contributor

    Please see #3170 -- the docs are incorrect but the situation is complex.

    I recommend you avoid using process.exit() whenever possible.

  2. added
    duplicateIssues and PRs that are duplicates of other issues or PRs.
    processIssues and PRs related to the process subsystem.
    on Nov 5, 2015
  3. Fishrock123 commented on Nov 5, 2015

    @Fishrock123
    Contributor

    Please also see #2972 (comment)

    (Oh dear, this again.)

  4. minesworld commented on Nov 5, 2015

    @minesworld
    Author

    Yes, this again. And shame on me that I thought node.js could be used to write a unix like tool without looking on the CLOSED issues. The "issue" thing here works as reliable as process.stdout/.stderr ...

  5. mikemaccana commented on May 17, 2016

    @mikemaccana
    Contributor

    See #6456 for the latest.

  6. added a commit that references this issue on Aug 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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