So I have a bit of a question, that relates both to k6 and to I guess JavaScript itself. (Also I realize k6 is built upon Go language but uses JS).
Anyways in K6 you have a default function that looks like this:
export default function () {
http.get('https://test.k6.io');
sleep(1);
}
In my scenario I need to wait 400ms between two different HTTP requests. K6 has an experimental setTimeout
function that does this. So I simply did the below:
export default () => {
http.patch(firstURL,body,params)
setTimeout(() => {
const res = http.post(secondURL,body,params)
console.log(res.status)
}, "400");
}
So this did indeed work. It appeared to wait 400ms before executing the second request. However my question is: While it's waiting for that 400ms to end, does the main default
function "end"?
As in will it move to the next iteration while that 400ms is finishing up, or will the default
function wait for everything to finish before it finally finishes itself? Apologies if the question is confusing, not sure of a better way to explain it.
My initial guess is that the execution stalls until the second request finishes anyways?