Skip to content

fix(health): remove TCP half-close that breaks Docker health check#2

Merged
tyrchen merged 2 commits intomasterfrom
fix/health-check-tcp-halfclose
Mar 8, 2026
Merged

fix(health): remove TCP half-close that breaks Docker health check#2
tyrchen merged 2 commits intomasterfrom
fix/health-check-tcp-halfclose

Conversation

@tyrchen
Copy link
Owner

@tyrchen tyrchen commented Mar 8, 2026

Summary

  • Root cause: The health check client called writer.shutdown() after sending the HTTP request, which sends a TCP FIN. Hyper interprets the FIN as the connection closing prematurely and aborts before sending the response — producing "connection closed before message completed" errors every 2s and marking the container unhealthy.
  • Fix: Remove the stream split and half-close. The GET request is self-framing and the Connection: close header tells hyper to close after responding, giving read_to_string its EOF naturally.
  • Downgrade connection-error log from error! to warn! since client resets are normal.

Closes #1

Test plan

  • cargo build / cargo test / cargo clippy pass
  • Run docker compose up with the image rebuilt from this branch and verify container shows (healthy)
  • Confirm no "connection closed before message completed" errors in logs

🤖 Generated with Claude Code

tyrchen and others added 2 commits March 8, 2026 09:17
The health check client called `writer.shutdown()` after sending the HTTP
request, which sends a TCP FIN to hyper.  Hyper's connection handler
interprets the FIN as a premature close and aborts before sending the
response, producing "connection closed before message completed" errors
every 2 seconds and marking the container unhealthy.

Remove the stream split and half-close — the GET request is self-framing
and the `Connection: close` header tells hyper to close after responding,
giving `read_to_string` its EOF naturally.

Also downgrade the connection-error log from `error!` to `warn!` since
client-side resets are expected in normal operation.

Closes #1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add integration tests that simulate the Docker HEALTHCHECK's raw TCP
health check pattern, verifying the server responds correctly without
TCP half-close.  Also add a CI step to the s3-test workflow that runs
the built-in --health-check flag and checks server logs for connection
errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tyrchen tyrchen merged commit a08b862 into master Mar 8, 2026
12 checks passed
@tyrchen tyrchen deleted the fix/health-check-tcp-halfclose branch March 8, 2026 17:02
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.

health check is not working

1 participant