Skip to content

fix: close HTTP response bodies to prevent OOM with many checks#1058

Open
dukelion wants to merge 1 commit into
goss-org:masterfrom
dukelion:fix/http-oom-response-body-cleanup
Open

fix: close HTTP response bodies to prevent OOM with many checks#1058
dukelion wants to merge 1 commit into
goss-org:masterfrom
dukelion:fix/http-oom-response-body-cleanup

Conversation

@dukelion
Copy link
Copy Markdown

@dukelion dukelion commented May 7, 2026

When running 100+ HTTP checks concurrently, response bodies were never closed if the check only validated status and headers (no body matcher). This caused unclosed TCP connections to accumulate, holding TLS state and transport buffers until the 10s client timeout expired, leading to OOM kills under memory limits.

Checklist
  • make test-all (UNIX) passes. CI will also test this
  • unit and/or integration tests are included (if applicable)
  • documentation is changed or added (if applicable)

Description of change

Fixes OOM when goss is configured with many HTTP checks and limited RAM.

  • Add Close() to system.HTTP interface and DefHTTP
  • Track whether Body() consumed the response body
  • Close() closes resp.Body if it wasn't consumed (i.e. status/headers-only checks)
  • resource/http.go Validate() defers sysHTTP.Close() for guaranteed cleanup

When running 100+ HTTP checks concurrently, response bodies were never
closed if the check only validated status and headers (no body matcher).
This caused unclosed TCP connections to accumulate, holding TLS state
and transport buffers until the 10s client timeout expired, leading to
OOM kills under memory limits.

Changes:
- Add Close() to system.HTTP interface and DefHTTP
- Track whether Body() consumed the response body
- Close() closes resp.Body if it wasn't consumed (i.e. status/headers-only checks)
- resource/http.go Validate() defers sysHTTP.Close() for guaranteed cleanup

Fixes OOM when goss is configured with many HTTP checks and limited RAM.
@dukelion dukelion requested a review from aelsabbahy as a code owner May 7, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant