-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Inconsistent behavior of exec.test.abort within a group #2849
Comments
Thanks for reporting this, I just tried it and can confirm it's a bug 😞 |
Something quite weird is going on 😕 The problem disappears when I try to run the test with 2 iterations, i.e. k6 exits with 108 even if the test is aborted in the middle of a We'll need to do some digging to figure out exactly what is causing this, but my bet is that our k6/js/modules/k6/execution/execution.go Lines 168 to 176 in 60b8b15
Lines 87 to 138 in 60b8b15
Something seems to mask the error 😕 |
Ok, so, if I add Line 740 in 60b8b15
I get this when I call
however, if I call it inside of a
So something is indeed transforming this very specific interrupt error into a generic exception 🤔 I think this might happen because Looking at how the whole handling of interrupt errors is done, there are quite a few special cases and things that have a bit of a code smell to them... 😞 I am not sure this code cannot be streamlined and simplified 🤔 With some more integration tests, of course, and an eye towards also improving #2804 🤞 Some examples of the special handling I noticed:
|
I think this part in goja is the thing that transforms our nice k6/vendor/github.com/dop251/goja/runtime.go Lines 1993 to 1999 in 60b8b15
We should be able to extract the internal error by following this advice, though that would require even more special handling like the one I complained about in the previous post 😞 Not sure there is a better alternative though. @mstoykov, any ideas? |
I have opened an upstream PR to fix it.
That was because the first iteration just gets an exception from the group returning the error and it being handled as exception. And the second one actually trying to run and hitting the interrupt error. |
Brief summary
If I use
exec.test.abort
inside agroup
call, the k6 script exits immediately, that's OK.But I got the exit code 0, while the documentation says it should be 108:
When I move the
exec.test.abort
call outside of the group, the exit code is108
(what I expect).k6 version
0.42.0
OS
Ubuntu 20.04
Docker version and image (if applicable)
docker.io/grafana/k6:0.42.0
Steps to reproduce the problem
Having 2 files:
abort-main.js
abort-group.js
And then, run k6 with both file, using
docker.io/grafana/k6:0.42.0
Docker image, and finally get the exit code ($?
), like this:docker run --rm -v $(pwd)/:/usr/local/me docker.io/grafana/k6:0.42.0 run /usr/local/me/my-file.js ; echo "exit code is:" $?
Expected behaviour
I expect following results:
will not be visible
andwill not be visible either
are not presentfailed message from main
andfailed message from group
are visibleActual behaviour
abort-main.js
results
default ✗
message)will not be visible
andwill not be visible either
are not presentfailed message from main
is visible (text is missing in the output)abort-group.js
results
default ✓
message)will not be visible
andwill not be visible either
are not presentfailed message from group
is visibleThe text was updated successfully, but these errors were encountered: