Skip to content

fix: report header-phase client disconnects as 499 client_canceled, not 502 - #76

Merged
jasonxu114514 merged 1 commit into
jasonxu114514:mainfrom
SK-DEV-AI:pr/client-cancel-499
Oct 15, 2026
Merged

jasonxu114514 merged 1 commit into
jasonxu114514:mainfrom
SK-DEV-AI:pr/client-cancel-499

Conversation

@SK-DEV-AI

Copy link
Copy Markdown
Contributor

A downstream disconnect during the upstream attempt loop is not an upstream failure, but the gateway answers it with 502 upstream_error on both the message endpoints and System One. Clients that retry on 502 then retry a request nobody cancelled, and telemetry counts client behavior as a server failure.

This checks wire.ClientCanceled before the generic 502: sets meta.Outcome so the request line reads client_canceled, and answers 499 with a client_canceled envelope. DeadlineExceeded keeps its 504.

Validation: go vet clean, go build -trimpath clean, gofmt clean. Error-path only; no hot-path change.

…ot 502

A downstream disconnect during the upstream attempt loop is not an
upstream failure, but the gateway answered it with 502 upstream_error on
both the message endpoints and System One. Clients that retry on 502
then retried a request nobody cancelled, and telemetry counted a client
behavior as a server failure.

Check wire.ClientCanceled before the generic 502: set meta.Outcome so
the request line reads client_canceled, and answer 499 with a
client_canceled envelope. DeadlineExceeded keeps its 504.
jasonxu114514 added a commit that referenced this pull request Oct 15, 2026
A downstream disconnect during the upstream attempt loop is not an
upstream failure, but it was answered with 502 upstream_error on both the
message endpoints and System One. Check wire.ClientCanceled before the
generic 502 and answer 499 client_canceled instead; an exhausted request
budget keeps its 504. Cancels log at debug before the request_failed
warning, so disconnects no longer read as upstream outages.

Co-authored-by: sk-dev-ai <[email protected]>
@jasonxu114514
jasonxu114514 merged commit 9a5b4e2 into jasonxu114514:main Oct 15, 2026
5 checks passed
SK-DEV-AI added a commit to SK-DEV-AI/opencode2api that referenced this pull request Oct 15, 2026
…ver-key usage)

Takes upstream f8e996d/be91f86/0204ca1 (client fingerprint + inference
endpoint + genuine tools), jasonxu114514#59 anon cooldown lockup, jasonxu114514#63 token floor,
jasonxu114514#64 whole-attempt deadline, jasonxu114514#62 tool images, jasonxu114514#58 server-key usage
split, jasonxu114514#65/jasonxu114514#66 models surface, plus our merged jasonxu114514#76/jasonxu114514#77/jasonxu114514#78.

Kept local (fork-owned, still no upstream equivalent): zero-delivery
replay + length rescue + SSE heartbeat + stop/tail census (stream
lanes), offline no_upstream_contact probe guard, single-marshal Zen
shaping with paid-model gate, tcp4 dial + TLS resumption, RandomID
math/rand fallback, cancel-detached refresh fix (PR jasonxu114514#80 superseded by
maintainer feedback; kept locally pending lifetime-context rework).
Telemetry takes upstream's session-burn + server-key split with their
LRU session cap (better than our smallest-first); CloneMap takes
upstream's merged comment. Metrics ring test retargeted at upstream's
concrete ring types. doUpstream keeps upstream's 3-value signature;
replay uses a new doUpstreamCounted wrapper for continuous legs.
SK-DEV-AI added a commit to SK-DEV-AI/opencode2api that referenced this pull request Oct 15, 2026
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.

2 participants