Repository navigation
Report caller disconnects as cancelled instead of provider outages - #1751
Merged
Merged
Conversation
When a client disconnects mid-call, the canceled request context makes the Firestore token read fail with a gRPC Canceled status. The catalog wraps that as an explicit "unavailable" error, so the callable layer logged a 503 error report for what was only the caller leaving. The callable server now checks the request's own context when a call fails: if the caller is gone, the call is reported as cancelled (499, info level), whatever error the handler returned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EzdqAWrbTMdtJutmK41coy
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
Error reporting logged this:
The client disconnected about 200ms into the call. That canceled the request context, so the Firestore token read in
provider.Service.AccessTokenreturned a gRPCCanceledstatus.catalog.userTokenthen wrapped it withupstreamError, which attaches an explicitcallable.Error{Code: "unavailable"}.canonical()checks for an explicit*Errorbefore it checks for cancellation, so the caller leaving was logged as a 503 server error.Fix
The
failpath incallable.Server.servenow checks the request's own context. Ifr.Context()was canceled, it puts acancellederror in front of the handler's error (fmt.Errorf("%w: %w", errCallerGone, e)). The call is then reported as 499 at info level, whatever the handler returned.This uses the request context as the source of truth instead of looking for cancellation inside the error. Every handler that wraps downstream failures in an explicit code is covered, not only
getEmotes. A real upstream outage while the caller is still connected is still reported as 503. ACanceledstatus coming back from a provider while the caller is still connected is still treated as a server-side failure.Tests
catalog.TestClientDisconnectIsNotProviderOutagereproduces the production log end to end: the client disconnects during the token read and the store returnsstatus.Error(codes.Canceled, ...). Before the fix it fails with the same503 / unavailable / errorlog entry as production.callable.TestCallerDisconnectOverridesExplicitErroris the unit-level version.TestContextErrorsUseCanonicalStatusstill confirms that an explicitunavailableerror without a disconnect stays 503.go test ./...passes except theinternal/youtubelive tests, which need network access to youtube.com (blocked in the sandbox where this was developed).Generated by Claude Code