fix(proxy): handle client-aborted streaming requests#209
Conversation
|
Warning Review limit reached
More reviews will be available in 34 minutes and 21 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR improves HTTP error handling across middleware and proxy layers. The middleware now correctly re-panics ChangesClient Abort and Disconnect Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR improves reverse-proxy handling of client-aborted streaming requests by distinguishing client cancellations from true upstream failures, and by letting http.ErrAbortHandler panics propagate so Go’s HTTP server suppresses benign abort logging.
Changes:
- Map proxy errors caused by request cancellation (
context.Canceled) to HTTP 499 (Client Closed Request) instead of returning 503. - Preserve 503 responses for genuine upstream/proxy failures while downgrading cancellation logging to debug level.
- Update panic recovery middleware to rethrow
http.ErrAbortHandler, with new tests covering both behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/adapters/in/http/proxy/forwarder.go | Returns 499 for canceled proxy requests and adjusts error classification/logging. |
| internal/adapters/in/http/proxy/forwarder_test.go | Adds a unit test asserting 499 is returned on context.Canceled from the transport. |
| internal/adapters/in/http/middleware/logging.go | Updates panic recovery to rethrow http.ErrAbortHandler so Go suppresses abort logs. |
| internal/adapters/in/http/middleware/logging_test.go | Adds coverage ensuring http.ErrAbortHandler panics are rethrown (not converted to 500). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func clientClosedRequest(w http.ResponseWriter) { | ||
| w.WriteHeader(statusClientClosedRequest) | ||
| } |
5d7fa7d to
8823050
Compare
Summary
http.ErrAbortHandlerpanics escape Gordon panic recovery so Go suppresses benign streaming abort logs.Test Plan
go test ./internal/adapters/in/http/proxy ./internal/adapters/in/http/middlewarego test ./...golangci-lint run ./...go vet ./...Summary by CodeRabbit
Release Notes