Request timeout; does it terminate the iteration?

Hello,
I’m running this code

response = http.get("https://some_url);
 check(response, {
    'Getting the data OK': (r) => r.status === 200),
  });

Sometimes I get an “context deadline exceeded k6” error.
However, when that happens, my check is still green.
Does it mean that the current iteration is exiting on timeouts, so the check is never run?

If no, what is the status of an timed-out request?

Hello and welcome to the forum!

We set the status to 0 when there is a timeout, and a timeout will not cause the iteration to end (you would have to use fail in order to do this).

I’m not able to reproduce this locally; my check definitely fails when a response took longer than the default timeout of 60s:

WARN[0060] Request Failed                                error="Get \"http://localhost:8080\": context deadline exceeded"

     ✗ Getting the data OK 
      ↳  0% — ✓ 0 / ✗ 1 

The code excerpt you’ve included in your post won’t actually compile, so I’m guessing this isn’t actually what you are running (URL string missing closing double-quotes; extra ), in the check function). Perhaps the check you have isn’t doing what you think it is?

Hello,
please check this example.

Seems the check on line 118 was never run.

Is that POST URL in the stack trace what vars["loginForm"] resolves to? Any chance you could share the code for the request immediately preceding the one on 110?

Hi Tom,
yes that is correct,
here it is.
The first request (line 96 ) follows a few 302 redirects.

Anyone else?
Seems like a bug to me.

Hi @Aleks,

You seem to have enabled the throw option, which as documented makes failed http requests into exceptions. “failed” here means ones that we totally didn’t managet to make or were not able to be finished in “unpredicatable” way as is the case with a timeout.

Example:

import http from "k6/http";

export default function() {
    http.get("https://test.k6.io", {timeout: "20ms"});
    console.log("next line");
}

just ran

and ran with throw enabled:

Hope this helps you