Skip to content

Fix idle connection leak in public health checks - #163

Open
kernaxis wants to merge 1 commit into
X4Applegate:mainfrom
kernaxis:fix/public-health-connection-leak
Open

kernaxis wants to merge 1 commit into
X4Applegate:mainfrom
kernaxis:fix/public-health-connection-leak

Conversation

@kernaxis

@kernaxis kernaxis commented Nov 2, 2026 •

Copy link
Copy Markdown

What & why

Public health checks create a new HTTP transport for every probe. When a response is fully consumed, its connection can remain idle indefinitely in a transport that is never reused.

Add defer client.CloseIdleConnections() after client creation. Deferred cleanup runs after the response body is closed, releasing idle connections while preserving existing probe behavior.

Add a regression test covering repeated HTTPS probes returning HTTP 200, 302 and 204. It verifies connection closure and persisted health results.

Related issue

none

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / internal (no behavior change)
  • Build / CI / tooling

Checklist

  • go build ./... compiles and go test ./... passes
  • Commits are clean (WIP squashed) and the PR is focused on one concern
  • Code matches the existing style (no new linters required)
  • User-facing change is noted in CHANGELOG.md with a version bump
  • Docs updated where relevant (README, in-app web/templates/docs.html, and/or the wiki)
  • I agree my contribution is licensed under the project's Apache License 2.0

Notes for reviewers

The regression test fails without the fix and passes with it. Existing public health tests also pass:

go test -mod=readonly ./internal/server \
  -run '^(TestCheckProxyHostClosesIdleConnections|TestCheckAllProxyHosts.*|TestPublicHealth.*)$' \
  -count=1

This PR contains only the connection cleanup and its regression test, no changelog or version bump is included.

This branch has not been deployed

No deployments
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