-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
promisify child_process.exec always rejects #19494
Comments
I don't think this is an actual bug.
The |
Yes, this is by design, this is also how the callback version works so it doesn't actually have to do with promises. Try
|
Maybe we should add a clarification to the docs: "If the process exits with a non-zero status code the promise is rejected" |
The docs for child_process exec already show that "Any exit code other than 0 is considered to be an error." https://github.com/nodejs/node/blame/master/doc/api/child_process.md#L193 |
@TomCoded correct, I was suggesting adding that clarification to the
Or something of the sort |
@TomCoded thanks, definitely missed that. I just assumed it would be on a fatal error of some sort, and would have a Checking the exit code will be fine. |
@benjamingr Oh, yes, something in the promisify section might be helpful. Perhaps |
@TomCoded would you be interested in submitting such a PR? (If you're unsure how to get started, let me know and we can walk through it on IRC/IM together, I also recommend checking out CONTRIBUTING.md) |
Will do. |
Promisify section of child_process.exec doc changed to make clear that non-zero exit codes will result in promise rejection. fixes: nodejs#19494
@benjamingr Submitted PR. (Thank you for the offer. I believe it worked, but I am still figuring out the system. Please have no qualms about suggestions/criticism.) Cheers, |
Promisify section of child_process.execFile doc changed to make clear that non-zero exit codes will result in promise rejection. fixes: nodejs#19494
Promisify sections of `child_process.exec()` and `child_process.execFile()` changed to make clear that non-zero exit codes will result in promise rejection. PR-URL: #19541 Fixes: #19494 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
v8.9.4
Ubuntu 16.04
I'm having trouble
promisify
ingchild_process.exec
. When I run with error or without, the promise is rejected. I've followed the docs and wrote this:fooBar
goes through thecatch
block with thiserror
:An actual error (or at least a 'no such file') gives me
code: 2
,stdout: ''
,stderr: no such file error string
The text was updated successfully, but these errors were encountered: