You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when a k6 extension panics, the k6 runtime "catches" the panic, simply skips the iteration and logs an error message like:
"time="2022-01-26T14:22:12-05:00" level=error msg="a panic occurred in VU code but was caught: record on line 1373: wrong number of fields" executor=constant-vus scenario=default"
There is no reasonable way to programmatically catch or report extension panics in k6 and apart from the log message they are essentially like a "silent" error.
For example if a load test has 10 iterations and all of them panic, k6 still considers the load test as a whole as successful.
k6 version
v0.35.0
OS
cross platform
Docker version and image (if applicable)
No response
Steps to reproduce the problem
create an extension method that instantly panics and call this method from a JS script
Expected behaviour
any (combination?) of these:
A panic bubbles up to the k6 JS layer as JS error and can be handled or ignored there
A panic stops the iteration but makes the iteration count as an "error" somewhere
A panic fails the k6 process with a non-zero exit code immediately
Actual behaviour
the k6 runtime "catches" the panic, simply skips the iteration and logs an error message like "time="2022-01-26T14:22:12-05:00" level=error msg="a panic occurred in VU code but was caught: record on line 1373: wrong number of fields" executor=constant-vus scenario=default". Otherwise it continues "as if" the iteration or loadtest was successful.
The text was updated successfully, but these errors were encountered:
A panic bubbles up to the k6 JS layer as JS error and can be handled or ignored there
I don't think this is possible, since a panic in VU code will generally interrupt the whole JS VM execution 😕 And even if it's technically possible, if there's a chance it leads to undefined behavior, we should probably avoid this approach unless we are absolutely sure it can work reliably.
A panic stops the iteration but makes the iteration count as an "error" somewhere
A panic fails the k6 process with a non-zero exit code immediately
These are somewhat connected to #877 and #1769. If Go panics emit an interrupted_iteration{cause:panic} metric, we can easily add a threshold that aborts the script based on that sub-metric 🤔
Brief summary
Currently when a k6 extension panics, the k6 runtime "catches" the panic, simply skips the iteration and logs an error message like:
There is no reasonable way to programmatically catch or report extension panics in k6 and apart from the log message they are essentially like a "silent" error.
For example if a load test has 10 iterations and all of them panic, k6 still considers the load test as a whole as successful.
k6 version
v0.35.0
OS
cross platform
Docker version and image (if applicable)
No response
Steps to reproduce the problem
create an extension method that instantly panics and call this method from a JS script
Expected behaviour
any (combination?) of these:
Actual behaviour
the k6 runtime "catches" the panic, simply skips the iteration and logs an error message like "time="2022-01-26T14:22:12-05:00" level=error msg="a panic occurred in VU code but was caught: record on line 1373: wrong number of fields" executor=constant-vus scenario=default". Otherwise it continues "as if" the iteration or loadtest was successful.
The text was updated successfully, but these errors were encountered: