Skip to content

child_process.exec not retrieving full stdout from jsdoc #3033

Closed

Description

@Macil

Since updating from node 0.12 to node 4.1.1, I've had an issue where the stdout from jsdoc (v3.3.2) specifically captured by child_process.exec has been cut off.

var cproc = require('child_process');
cproc.exec('jsdoc aaa.js -t templates/haruki -d console -q format=json', function(err, stdout, stderr) {
  if (err || stderr) {
    console.error('err', err);
    console.error('stderr', stderr);
  }
  console.log('stdout.length', stdout.length);
});

(aaa.js, nothing special besides that its jsdoc output should be longer than 8192 bytes.)

The above program should output "stdout.length 9778", but now that I have node 4 it outputs "stdout.length 8192". If I run jsdoc aaa.js -t templates/haruki -d console -q format=json | wc -m, I get 9778 as expected, so the issue does not seem to be that jsdoc is cutting itself off.

(Note that if I run the script with node 0.12 but still use node 4.1.1 to run jsdoc, I still get the issue, so the issue does not seem to be a new regression with child_process.exec. Running the above script with either version of node and using node 0.12 to run jsdoc causes the issue to not happen. I assume some minor change in node 4 changed how the output from jsdoc is buffered in a way that triggers a longstanding child_process.exec bug if you try to read that output? Maybe it could be a bug with jsdoc, but I'm not seeing how that would likely unless jsdoc is doing something really weird.)

Activity

  1. added
    child_process
    on Sep 23, 2015
  2. mscdex commented on Sep 23, 2015

    @mscdex
    Contributor

    It looks like jsdoc explicitly calls process.exit() which could be a problem if stdout/stderr writes haven't finished before process.exit() is called. See #2972.

  3. Macil commented on Sep 23, 2015

    @Macil
    Author

    That looks like the issue. I'll close this as it's a duplicate of that and/or an issue with jsdoc.

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

    child_process

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions