Repository navigation
fix(proxy): a probe that returns no response must fail the proxy, not just timeouts and refusals - #111
Merged
jasonxu114514 merged 1 commit intoOct 23, 2026
Conversation
checkClaimedProxy() only marked a proxy unhealthy when the probe error was a timeout or ECONNREFUSED (isProxyFailure). A proxy that answers the CONNECT with its own error -- e.g. a provider refusing because the plan's bandwidth is exhausted -- produced an error matching none of those cases, so the probe was reported as inconclusive and the proxy stayed healthy forever: never taken out of rotation and never re-bound for key traffic. A probe is a plain HTTP GET issued through the proxy; if it returns no response, that proxy cannot serve traffic, whatever the reason. Count every non-cancellation error as a failure. context.Canceled stays exempt because it says the caller gave up, not that the proxy is down. Scope: the probe path only. syncProxyResult() (real traffic) and the anonymous attempt loop keep using isProxyFailure deliberately -- there an error may come from the upstream rather than the proxy, so staying conservative is correct.
WengeLiu101
pushed a commit
to WengeLiu101/opencode2api
that referenced
this pull request
Oct 24, 2026
TiaraBasori
added a commit
to TiaraBasori/opencode2api-1
that referenced
this pull request
Oct 25, 2026
…breaker) Pick up origin/main (19 commits since v1.4.3): - 2.1.1 client shape: version bump, /inference/openai|anthropic family routes, max_completion_tokens 32000, strict:false tools, client key order, no HTML escaping, runtime-owned Accept/Content-Length (jasonxu114514#141-jasonxu114514#143) - anonymous-lane abuse handling: IP-block detection, per-exit block TTL, circuit breaker (models.anonymous_backoff), max_anonymous_exits cap, deterministic 4xx stops the walk instead of replaying every exit - placeholder key dropping, probe failure classification (jasonxu114514#111), WebUI Cache-Control (jasonxu114514#112), reasoning disable preserved end to end (jasonxu114514#150), Italian README/WebUI Conflict resolutions: - internal/config/config.go, README.md, README.zh-CN.md: kept both sides — the alias fields (aliases/strip_free_suffix) and the new anonymous_backoff block sit side by side in ModelsConfig and the README tables. Local adaptation for this deployment's #pool exit (not upstream): - a #pool transport dials a fresh upstream address on every attempt, so an IP-scoped abuse block cannot be parked on the transport: blocked() and markBlocked() ignore pool transports and the anonymous walk keeps rotating instead of freezing every exit behind one flagged address.
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
checkClaimedProxy()decides a proxy's health from a probe — a plain HTTP GET issued through the proxy.When the probe returns no response, the failure is classified by
isProxyFailure(), which recognizes onlycontext.DeadlineExceeded,syscall.ECONNREFUSEDand deadline timeouts. Everything else is reported ashealth_check_inconclusiveand leaves the proxy marked healthy.That misses the failure a metered proxy pool produces most often: the proxy accepts the TCP connection and then
answers the CONNECT with its own error — an exhausted-bandwidth / quota response, a provider-side tunnel error,
a reset. The proxy is unusable but stays "healthy" forever: never taken out of rotation, never re-bound for key
traffic. The pool keeps handing it out and every request through it fails.
Fix
A probe that returns no response means the proxy cannot currently serve traffic, whatever the reason.
result := proxyHealthResult{proxy: proxy, err: err, wasHealthy: proxy.healthy.Load()} if err == nil { result.wasHealthy = proxy.healthy.Swap(true) - } else if isProxyFailure(err) { + } else if !errors.Is(err, context.Canceled) { result.failed = true result.wasHealthy = proxy.healthy.Swap(false) }context.Canceledstays exempt: it says the caller gave up, not that the proxy is down.Scope
The probe path only.
syncProxyResult()(real traffic) and the anonymous attempt loop keep usingisProxyFailure()deliberately — there an error can originate upstream rather than from the proxy, so stayingconservative is right.
isProxyFailuretherefore stays in use and does not become dead code.Verification
Measured on a local build (v1.4.0 + this change) with a pool of 60 proxies whose CONNECT is answered with the
provider's bandwidth error (TCP connects, CONNECT never completes):
checkClaimedProxyoutcomehealth_check_inconclusiveisProxyFailureandcheckClaimedProxyare byte-identical onmainto the v1.4.0 I measured against, so thesame code path applies here.
Notes