Responses of GET requests seems to be empty when running in scenario mode

Hi!

I am currently facing a weird problem, which might not be described in the docs. I have GET calls, where I need the body of the response for the next call.

After some time in a scenario the response seems to be empty and parsing of the document is not possible. It looks like k6 is neglecting the responses (discardResponseBodies = false). When I had a look at the response they were just empty. It occurs in every scenario no matter what scenario type is configured.

The weird thing is that when running the exactly same script without scenario and with default function (standard mode), the script is running decent.

Error message:

My config:

export let options = {
scenarios: {
regular_api_test: {
executor: ‘ramping-vus’,
stages: [
{ duration: ‘2m’, target: 10 },
{ duration: ‘4m’, target: 40 },
{ duration: ‘2m’, target: 10 }
],
gracefulRampDown: ‘30s’,
exec: ‘regular’,
},
visit_transfer_api_test: {
executor: ‘constant-arrival-rate’,
rate: 5,
timeUnit: ‘1m’,
duration: ‘8m’,
preAllocatedVUs: 20,
maxVUs: 40,
exec: ‘visittransfer’
}
}
}

Is there something I did wrong in the configuration? Or could it be a possible bug?

Help is appreciated!

1 Like

Hi @mma,

I would guess that you are getting either timeout requests due to the system under test or k6 not being able to handle the traffic. Or just any other kind of not expected status code (500 for example) which leads to the body being empty.

You can probably print the response in case of problems as in

try {
  res.json() 
} catch (e) {
  console.log(JSON.stringify(res, null, "  ")); 
}

and try to see what is happening

Hello,

I am facing the same problem. Is there any solution yet?
Respose is 200 OK. It works with some other endpoints. I don’t find any pattern in the behavior. Some JSON response work correclty, but a simple “Hello World” response from a test endpoint turns into an empty body in K6.
It works correctly with postman or other clients.

Best
Clemens

Hi @tanc, welcome to the community forum :tada: !

Have you tried the proposed way to debu this above - JSON.stringify-ing the whole response on errors?

I still have no idea what happened originally as the original poster didn’t come back so :person_shrugging:

Hi,
I found the problem. My fault. I have used a wrong authentication token and my endpoint responded with 200 OK, which is totally wrong and was missleading. Works fine now.
Sorry, has been my fault!

Best
Clemens

1 Like