-
Notifications
You must be signed in to change notification settings - Fork 5
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
throwOnError should default to true #39
Comments
The conclusion in the issue was that we add a Changing the default is a big breaking change I think. Id like to see more discussion here to know it's the right thing to do or not. If you know anyone relevant, please do cc them in |
From what I understand, in that issue #32 (comment), #32 (comment), and #32 (comment) support throwing on non-zero exit codes by default. Only #32 (comment) mention sticking with node's behaviour. And if But anyways I think whether the option will be the default or not, I probably have to wrap all usages of If we decide that we don't want to set |
I'm open to setting the default to true, I just wanted some more opinions if possible since we're the only two people here and tinyexec has a lot of users now But I'm not sure who best to pull in I feel like most of the big consumers are ones we migrated at least, so should be easy to update But it would be very helpful to get an idea of how many consumers check the exit code right now instead of throwing (i.e can we get at least one example of a consumer that isn't prepared for us introducing exceptions) |
Here's some I searched around that could benefit from
But given those, there's also a fair share of code that is missing handling exit code 1, and Personally, I think it's better to decide what the default value from an API design & ergonomics point-of-view rather than how it affects existing consumers and breaking changes, because adoption is only going to keep getting higher from here 😅 But to be honest, I'd also prefer the error message to be a little better if we ended up pushing `true` by default for everyone, because currently it's quite hard to read. I hope it could look something like this (click to open)NonZeroExitError: Process started with `pnpm run asdf` returned exit code 1
ERR_PNPM_NO_SCRIPT Missing script: asdf
Command "asdfsg" not found.
at ...
at ... Code: import { exec } from 'tinyexec';
try {
await exec('pnpm', ['run', 'asdf'], { throwOnError: true });
} catch (e) {
throw e;
// console.log(e);
} Right now it returns: x [Error]: Process exited with non-zero status (1)
at ...
at ... {
result: R {
_process: ChildProcess {
... hundreds of lines of stuff related to child process
}
},
output: {
stderr: '',
stdout: ' ERR_PNPM_NO_SCRIPT Missing script: asdf\n' +
'\n' +
'Command "asdf" not found.\n'
}
} |
Of course 👍 we are deciding based on API design, not existing consumers. But we need to know about existing consumers so we can get them to update their usage (or we do it for them) Anywhere a person currently does not try/catch and checks the exit code will need to update I'm in agreement I think about changing the default but we will need to help update various projects |
I'm a bit confused of the conclusion at #32. Isn't that the
exec()
should throw on non-zero exit code by default?I just noticed this bug in Astro and for all its usage it should be throwing on error by default. It feels like the more sensible default to me.
The text was updated successfully, but these errors were encountered: