Why i get status 302 insted of 200

Hi everyone ,

I’m working in a project that emulate a user journey, so the test includes h2 (document, document/redirect and XHR) requests.

When i check the report from the execution in K6 Cloud > (tab) HTTP , i notice that one same url got 4 different status:

0, 500: what i expected when it fails
200: what i expected as a good result (for documents)
302: here is the question ¿?

In all my request i set “redirects: 0” in params section and this request only get 200 in the browser’s console.

Thanks for your answers.
Gino.

Hi @Gino,
if you set the max redirects option to zero it means that it will not follow the redirect so the response will be tracked with the latest seen status so the 302.

If the metric’s value says you should see it for all the requests then you could just run k6 with --iteration 1 and –http-debug flags enabled and see what is the returned flow.

You could also consider adding a check on the status so k6 generates a rate metric and you can get an accurate percentage of the event.

Instead, if it isn’t deterministic you should add a console.log when the response.status is 302 and inspect the response. You could do the same with the k6 debugger.

Let me know if it helps.

Hi @codebien , thanks for the recommendation, I used a control to review the requests with stauts 302 and I have noticed that the request appears twice because in addition to the request that I sent (which does return 200) there was another request that redirected to it (this generated status 302) and that did not include the redirects: 0 that I had set.

I finally made some adjustments and they no longer appear in the reports. Thank you.
Gino

@Gino Can you please tell me what did you do apart from setting redirects: 0