Skip to content

Report caller disconnects as cancelled instead of provider outages - #1751

Merged
kevmo314 merged 1 commit into
mainfrom
claude/eager-dijkstra-hdrup8
Oct 30, 2026
Merged

kevmo314 merged 1 commit into
mainfrom
claude/eager-dijkstra-hdrup8

Conversation

@kevmo314

Copy link
Copy Markdown
Contributor

Problem

Error reporting logged this:

HTTP POST /getEmotes returned 503: twitch access token: provider temporarily unavailable: rpc error: code = Canceled desc = context canceled

The client disconnected about 200ms into the call. That canceled the request context, so the Firestore token read in provider.Service.AccessToken returned a gRPC Canceled status. catalog.userToken then wrapped it with upstreamError, which attaches an explicit callable.Error{Code: "unavailable"}. canonical() checks for an explicit *Error before it checks for cancellation, so the caller leaving was logged as a 503 server error.

Fix

The fail path in callable.Server.serve now checks the request's own context. If r.Context() was canceled, it puts a cancelled error 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. A Canceled status coming back from a provider while the caller is still connected is still treated as a server-side failure.

Tests

  • catalog.TestClientDisconnectIsNotProviderOutage reproduces the production log end to end: the client disconnects during the token read and the store returns status.Error(codes.Canceled, ...). Before the fix it fails with the same 503 / unavailable / error log entry as production.
  • callable.TestCallerDisconnectOverridesExplicitError is the unit-level version.
  • The existing TestContextErrorsUseCanonicalStatus still confirms that an explicit unavailable error without a disconnect stays 503.

go test ./... passes except the internal/youtube live tests, which need network access to youtube.com (blocked in the sandbox where this was developed).


Generated by Claude Code

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
@kevmo314
kevmo314 merged commit af7d4de into main Oct 30, 2026
8 checks passed
@kevmo314
kevmo314 deleted the claude/eager-dijkstra-hdrup8 branch October 30, 2026 18:22
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