Closed pawelgalazka closed 7 years ago
If async call run
fails without handling promise rejection, process will still finish with exit code 0
(success). Pure node
process by default prints unhandled promise rejection
warning in that case (unhandled rejection) and exit with code 0
, let's keep that behaviour, so this won't be fixed.
Possible suggestion / idea for this since it wasn't exactly intuitive to me why runs I had changed from sync to async were still passing on errors...
Can we return a promise, and then have failures cause the exit?
Eg.
export function blah() {
return run('cmd', {async: true});
}
Since the promise is returned runjs could catch any reject and return status code 1.
Otherwise I'm guessing the suggested workaround is this for every async test?:
export function blah() {
run('cmd', {async: true})
.catch((err) => {
process.exit(1);
});
}
Thanks!
Yes, second example is the way to go. Generally runjs inherits nodejs default behaviour when it comes to handling failures for async processes, that means that parent process will still return success code 0 if async process fails. So it's up to developer how to handle async failures so it has full control of it.
Is this behavior changed in taskfile
? It can be a nasty surprise to a have a build fail, but have the build continue to deploy stage because the run command returned success instead of failure.
When
run('cmd', {async: true})
fails, process will exit with status code0
. Should be1
.