Repository navigation
Add NODE_DEBUG support for child_process #720
Description
Activity
I think going and having the error include the cmd during onexit would be sane as well.
That information is already included with the error:
var spawn = require('child_process').spawn; var child = spawn('fdjslkdf'); child.on('error', function (err) { console.error(err.syscall); console.error(err.path); throw err; });
Output:
$ ./iojs /tmp/cp-test.js spawn fdjslkdf fdjslkdf /tmp/cp-test.js:8 throw err; ^ Error: spawn fdjslkdf ENOENTWhat does seem to be missing is the list of arguments. I wouldn't mind an additional field being added for that.
Also. Looks like you aren't running the absolute latest. As of bc2c85c some of the information you're requesting has already been included.
- addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.and removedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
on Feb 5, 2015 Ah, shoot... I was running this with joyent/node, not io.js. My bad.
np. And if you want to PR to add a field to
errthat includes the arguments passed tospawn()you're welcome to.it is only in errors, not for when things get spawned (which is useful anyway)
@trevnorris @bmeck How do you feel about this?
var spawn = require('child_process').spawn; var path = require('path'); var child = spawn('fdjslkdf', ['--foo', 'bar'], { cwd: path.join(process.cwd(), './bat') }); child.on('error', function (err) { throw err; });
$ NODE_DEBUG=child_process ./iojs tmp.js CHILD_PROCESS 72525: command: fdjslkdf CHILD_PROCESS 72525: arguments: --foo,bar CHILD_PROCESS 72525: options: {"cwd":"/Users/zach/Documents/github/remixz/io.js/bat"} /Users/zach/Documents/github/remixz/io.js/tmp.js:9 throw err; ^ Error: spawn fdjslkdf --foo bar ENOENT at exports._errnoException (util.js:738:11) at Process.ChildProcess._handle.onexit (child_process.js:1029:32) at child_process.js:1120:20 at process._tickCallback (node.js:337:11) at Function.Module.runMain (module.js:489:11) at startup (node.js:111:16) at node.js:799:3It adds the arguments to the error, and adds the debug info. If you like it, I'll send a PR!
I have a small concern about adding the arguments to the error message, as it could get long in some cases. If it was just another property on the error object, that would be great.
EDIT: I think a PR would be good.
- addedchild_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.
on Feb 5, 2015 +1 to adding them to the error object but not in the message
- added a commit that references this issue
on Feb 5, 2015 Closed in 9a8f186
Since you have to enable debug I think leaving it in is ideal, since it is during debugging, when you want a plethora of information.
It would be super useful to have
NODE_DEBUGsupport forchild_process. The use-case that I'd have for this would be to track down when a command can't be found, since right now, all that's returned isError: spawn ENOENT. It'd be nice to have what command and arguments it was trying to run.Example:
Current output:
Idea of output: