Different exit codes for different errors #870
Labels
docs
enhancement
evaluation needed
proposal needs to be validated or tested before fully implementing it in k6
feature
ux
Currently k6 has only a few exit codes we specifically set -
98
and99
:k6 run
with a failed threshold will return99
(code)k6 cloud
will fail with98
if it couldn't get the test progress for some reason (I think) like network failure and with99
if the test run itself failed (code)k6
will otherwise exit with 0 if there were no errors or with255
for anything else that fails in a controlled manner, i.e. anything that's not a panic or OOM (code).(Go panics could also make k6 exit with a few different exit codes, though we've hopefully mostly eliminated them in k6, this is the only one we've recently seen. Skimming this file, it seems like most of the time
exit(2)
should be called, but technically it's also possible to haveexit(4)
andexit(5)
when panicking, even if unlikely...)This issue is a proposition that different types of errors should cause k6 to exit with different error codes. We should reserve a range and define, document and distinguish between errors - config validation errors, script errors in the init phase, script errors in the setup or teardown phases, crossed script errors threshold (will write another issue about that), etc. When we've defined a range for k6 system exit codes, we can also define a range for user error codes and allow users to specify them in the thresholds configurations, as requested in this issue.
These enhancements could be very useful when using k6 in a CI environment.
The text was updated successfully, but these errors were encountered: