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
import{sleep}from"k6";constsleepTime=parseFloat(__ENV.sleep);exportfunctionsetup(){sleep(sleepTime);console.log("setup successful");return"setup successful";}exportdefaultfunction(data){console.log("default with setup "+JSON.stringify(data));}exportfunctionteardown(){sleep(sleepTime);console.log("teardown successful");}
If I execute it with k6 run -e sleep=11 xt.js (the default timeouts for the setup() and teardown() functions is 10 seconds), I consistently get the expected Engine error with a message setup: context cancelled at setup (...). Despite not changing the k6 exit code (link to issue about it) and the very poor error message (sigh), the timeout works consistently and aborts the script correctly.
When I run the script with k6 run -e sleep=11 --no-setup --no-teardown --paused xt.js on the other hand, and I trigger the setup execution via the k6 REST API with curl -i -XPOST http://127.0.0.1:6565/v1/setup, some of the time I correctly get HTTP/1.1 500 Internal Server Error with body {"errors":[{"status":"500","title":"Error executing setup","detail":"setup: context cancelled at setup (...)"}]}, but most of the time k6 actually ignores the timeout and I get HTTP/1.1 200 OK with a body {"data":{"type":"setupData","id":"default","attributes":{"data":"setup successful"}}}
Increasing the sleep time to 21 (k6 run -e sleep=21 --no-setup --no-teardown --paused xt.js for example) seems to somewhat ameliorate the issue, in that there are fewer 200 responses, but it still doesn't completely fix it! Splitting the sleep() call in the setup() function to sleep(sleepTime/2); sleep(sleepTime/2); on the other hand causes the issue to disappear completely, at least as far as I can test. So this seems to be some sort of channel select issue where the timeouts don't always register?
The text was updated successfully, but these errors were encountered:
I have been able to reproduce this with setting GOMAXPROCS=1 otherwise I was having trouble.Running with GOMAXPROCS=2 I got 2 out of 100 runs and without it I didn't get a single 200 for about hour and half maybe two that I tried.
I guess your setup will lead to the same end result @na-- ?
Previously because of the way js interrupt works it was that the js vm
will not get interrupt signal for some time after the timeout has
happened. This would be especially true in cases of lower (1) cpu counts
or under heavy load.
Because calls from inside js to go code will return when the
context is *Done* we will probably still end setup/teardown functions in
approximately timeout time but it might not actually be marked as
timeouted.
To fix this after calls to js functions we check that the timeout has
been passed if setted. If this has happened we return a new specific
timeout error that can later be used to distinguish that timeout has
happened. There is also some additional code to catch that an actual
interrupt has happened and that it is because of timeout.
I have the following k6 script:
If I execute it with
k6 run -e sleep=11 xt.js
(the default timeouts for thesetup()
andteardown()
functions is 10 seconds), I consistently get the expectedEngine error
with a messagesetup: context cancelled at setup (...)
. Despite not changing the k6 exit code (link to issue about it) and the very poor error message (sigh), the timeout works consistently and aborts the script correctly.When I run the script with
k6 run -e sleep=11 --no-setup --no-teardown --paused xt.js
on the other hand, and I trigger the setup execution via the k6 REST API withcurl -i -XPOST http://127.0.0.1:6565/v1/setup
, some of the time I correctly getHTTP/1.1 500 Internal Server Error
with body{"errors":[{"status":"500","title":"Error executing setup","detail":"setup: context cancelled at setup (...)"}]}
, but most of the time k6 actually ignores the timeout and I getHTTP/1.1 200 OK
with a body{"data":{"type":"setupData","id":"default","attributes":{"data":"setup successful"}}}
Increasing the sleep time to 21 (
k6 run -e sleep=21 --no-setup --no-teardown --paused xt.js
for example) seems to somewhat ameliorate the issue, in that there are fewer200
responses, but it still doesn't completely fix it! Splitting thesleep()
call in thesetup()
function tosleep(sleepTime/2); sleep(sleepTime/2);
on the other hand causes the issue to disappear completely, at least as far as I can test. So this seems to be some sort of channel select issue where the timeouts don't always register?The text was updated successfully, but these errors were encountered: