"error decompressing response body (EOF)" despite http request returning 204

I’m running into this error where k6 fails to decompress a response body where it shouldn’t, given that, well, it’s a 204 http response. Here’s k6’s output with the http-debug=full flag. This was run against our loadtest instance on gcloud that replicates production. It happens consistently with all endpoints that return 204.

INFO[0005] Response:
HTTP/2.0 204 No Content
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Cache-Control: no-store
Content-Encoding: gzip
Content-Type: application/json;charset=utf-8
Date: Wed, 01 Nov 2023 19:19:28 GMT
Server: nginx
Set-Cookie: NO-XSRF-TOKEN=; Path=/; Expires=Fri, 01-Dec-2023 17:30:50 GMT; Secure
Set-Cookie: JWT-Cookie=; Path=/; Expires=Fri, 01-Dec-2023 17:30:50 GMT; HttpOnly; Secure; SameSite=Lax
Strict-Transport-Security: max-age=31536000
Vary: Accept-Encoding
Via: 1.1 google
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Xss-Protection: 1; mode=block

group="::Upload::Delete File" iter=0 request_id=e3419c60-b2db-4eb8-7899-142f96105283
scenario=upload_smoke_test source=http-debug vu=1 file=Basic

WARN[0005] Request Failed       error="error decompressing response body (EOF)"

The same error doesn’t happen locally where we don’t have nginx. I tried creating an expressjs app to reproduce and isolate the error, but it seems to only happen when nginx is involved.


If you add the encoding header (which I did and thought nothing of it) to your request, this error happens. I have removed it and k6 can now decompress 204 http responses normally.

For documentation, this is what I added:

"Accept-Encoding": "gzip,deflate,br"

Hi @cyberglot,

While your proposal does fix the problem for you and given some blog I found might fix it for everybody.

It still isn’t great that k6 does try to decode this even though there should be nothing.

As such I did make a fairly quick bugfix with some more info

I did fork k6 and coded a fix (albeit poorly), but then I realised that 204 is fairly messy/controversial and that I shouldn’t bother opening a PR.

Regardless, thank you so much for looking into it. Highly appreciated.

1 Like