Repository navigation
fix(proxy): do not probe a proxy after a client-canceled request - #185
Open
gerarecipe wants to merge 1 commit into
Open
gerarecipe wants to merge 1 commit into
gerarecipe wants to merge 1 commit into
Conversation
A request the client abandons ends with context.Canceled and no HTTP response. syncProxyResult still started a confirming health check for it, on a context without cancellation, and since jasonxu114514#111 any failed check marks the proxy unavailable and moves its keys. A canceled request says nothing about the proxy; checkClaimedProxy already exempts context.Canceled for the same reason. Skip the confirming probe for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
When a client abandons a request (closes the connection, cancels a stream before the first byte), the attempt ends with
context.Canceledand no HTTP response.syncProxyResulttreats that like any other upstream request error and starts a confirming proxy health check.That check runs on
context.WithoutCancel(ctx)by design, so it really goes out through the proxy. Since #111, any failed check marks the proxy unavailable and moves its keys. A client hanging up therefore costs an extra request through the exit, and if that check happens to fail for an unrelated reason the proxy is evicted and its keys rebound — although the proxy never failed.Root cause
checkClaimedProxyalready exemptscontext.Canceled("a caller that went away says nothing about the route"), butsyncProxyResultdecides to start the check before that exemption can apply, and the check itself no longer carries the cancellation.Change
In
syncProxyResult, return early forerrors.Is(err, context.Canceled)instead of callingverifyProxyAfterError. Nothing else moves: real transport failures (isProxyFailure) are handled before this branch, and other request errors still trigger the confirming check exactly as #111 intends. A wrappedcontext.Canceledis covered byerrors.Is.Verification
gofmt -l .,go vet ./..., Linux and Windows builds: clean._test.gofiles, so none is added. A throwaway test (not committed) calledsyncProxyResultwithcontext.Canceledand with a wrappedcontext.Canceled: no check was started and the proxy stayed healthy; the same test fails on currentmain(a check is started). Happy to add it if you want tests in the tree.🤖 Generated with Claude Code