Skip to content

[cleanup] Add missing resp.Body.Close() to prevent connection leaks - #1280

Merged
manugarg merged 1 commit into
mainfrom
fix/close-http-response-bodies
Mar 29, 2026
Merged

manugarg merged 1 commit into
mainfrom
fix/close-http-response-bodies

Conversation

@manugarg

Copy link
Copy Markdown
Contributor

Several HTTP client call sites were not closing the response body, causing TCP connection/file descriptor leaks on every request:

  • common/oauth/http_token.go: OAuth token fetch
  • internal/rds/kubernetes/client.go: Kubernetes API calls
  • internal/surfacers/datadog/client.go: Datadog metrics submission
  • internal/rds/gcp/gce_instances.go: GCP instance discovery
  • internal/alerting/notifier/http_notifier.go: use defer for Close

Several HTTP client call sites were not closing the response body,
causing TCP connection/file descriptor leaks on every request:

- common/oauth/http_token.go: OAuth token fetch
- internal/rds/kubernetes/client.go: Kubernetes API calls
- internal/surfacers/datadog/client.go: Datadog metrics submission
- internal/rds/gcp/gce_instances.go: GCP instance discovery
- internal/alerting/notifier/http_notifier.go: use defer for Close
@manugarg
manugarg force-pushed the fix/close-http-response-bodies branch from 8787151 to 5935d88 Compare March 29, 2026 02:04
@manugarg manugarg changed the title Add missing resp.Body.Close() to prevent connection leaks [cleanup] Add missing resp.Body.Close() to prevent connection leaks Mar 29, 2026
@manugarg
manugarg merged commit 4572629 into main Mar 29, 2026
12 checks passed
@manugarg
manugarg deleted the fix/close-http-response-bodies branch March 29, 2026 02:39
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