Repository navigation
fix: cancel HTTP requests when tracked connections close - #33
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues remain, and focused regressions cover cancellation races and preserved connection behavior.
Review effort: Balanced
Findings: None
What changed in this PR
Ensures forced HTTP shutdown cancels pending requests even when pipelining prevents socket-close detection.
Changes:
- Bind HTTP connection contexts to tracked full closure, canceling before admission-slot release.
- Add lifecycle and shutdown regressions, including graceful completion and TCP half-close.
- Document source-build behavior and cancellation limits.
| File | Description |
|---|---|
| internal/proxy/lifecycle.go | Synchronizes context binding and close cancellation. |
| internal/proxy/lifecycle_context_test.go | Tests races, cancellation ordering, ownership, and half-close. |
| internal/proxy/http.go | Binds accepted HTTP connections to cancellation. |
| internal/proxy/http_shutdown_cancel_test.go | Tests forced, graceful, and pending CONNECT shutdown. |
| docs/DEPLOYMENT.md | Explains shutdown cancellation and release availability. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Forced HTTP shutdown could close a tracked client socket and release its admission slot while a pipelined request kept waiting for upstream response headers. net/http may already have cached a pipelined byte, so its background reader cannot observe the close.
Bind each accepted HTTP connection context to tracked full close, with cancellation outside locks before tracker release. Registration racing with close returns a canceled child context. Graceful completion, CONNECT buffered bytes, TCP half-close, and shared dialer ownership remain intact.
Validation:
make checkand shuffledmake racepassed.Local first full attempts also exposed an ignored historical
.godiagnostic being compiled by./...; it was preserved as.go.txtand its overlay corrected before successful complete reruns. This artifact-only correction is not part of the PR.This change is source-build behavior, not included in v1.0.1. It establishes lifecycle correctness only; custom operations ignoring context remain outside cancellation guarantees. No dependency or release/tag change.
Exact-head validation (
022ead1175128071cef0a1892c09404538526c08): CI passed all 11 jobs, CodeQL passed, and Linux netem passed. Container logs confirm integration success and OCI image export; netem logs confirm suite success. All completed on their first attempt.Merged as
f4c8e880225edf873c6c87cf5b748de68cdc8360; local main and origin/main are synchronized with the identical tested tree. Main push CI passed all 11 jobs, CodeQL passed, and Linux netem passed, all on attempt 1. Actual main container/netem logs were verified. All eight new top-level regressions also passed under race ten times on merged main. No release/tag change.