Does an iteration wait for any pending requests even if they are async?

I’m using the asyncRequest in an iteration like this

export default function () {
  const token = `${__ENV.AUTH_TOKEN}`;
  const target = `${__ENV.TARGET}`
  const params = {
      headers: {
        'Content-Type': 'application/json',
        'Authorization': token

  http.asyncRequest('GET',uri,null, params)


And I’m targeting two different services with the same scenario and achieving totally different offered loads (aka rate(k6_http_reqs_total[1m])). By using an asyncRequest + discardResponseBodies: true and doing nothing with the response I was expecting k6 to keep hitting the server independently of receiving responses or not.
So the question is
Does an iteration completes only when all in fly requests (even asynchronous ones) complete?

BTW I know there is a constant-arrival-rate executor that starts iterations independently of target responses.

Hi @gabrielgiussi1, welcome to the community forum!

Yes all asynchronous operations (requests or not) must end before the iteration can finish.

There isn’t really a way for a JS engine to know if you will or will not use a result. And even if it could, it doesn’t really make senses to have asynchronous operations from previous iteration running in the same JS VM.

And if we should wait for the result it will make writing code really hard if you have multiple iterations running in the same JS VM. Whatever that will mean.

Hope this helps you!

1 Like