Skip to content

Log requests the caller abandoned as 499, not server errors - #1778

Merged
kevmo314 merged 1 commit into
mainfrom
claude/eager-dijkstra-hdrup8
Nov 13, 2026
Merged

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

Conversation

@kevmo314

Copy link
Copy Markdown
Contributor

Problem

Error group CKKelvOqqIPn0QE:

HTTP GET /embed returned 502   (latency_ms 1.5)

A 1.5ms 502 never reached Twitch or Kick. Since #1770, the app's stream preview WebView loads /embed directly, and it aborts that request in two cases:

  • when the preview closes: StreamPreview.dispose loads a blank page on iOS to silence audio
  • when it switches channel: didUpdateWidget loads a new URL

Once the client has gone, the request context is canceled. The handler's twitch...User or kick...Get then fails at once, and /embed answers 502 provider unavailable. LoggingMiddleware logs any status of 500 or above as an error.

This is the same pattern #1751 fixed for callables, this time on the plain-HTTP routes.

Fix

LoggingMiddleware fronts /embed, /embedRedirect, /metadata, /api/metadata, /auth/ and the webhook prefixes. When a request's own context was canceled, it now records the request as 499 at info level, whatever the handler wrote. That one check covers every route.

A server failure while the caller is still connected is still logged as an error (TestLoggingMiddleware). Webhook persistence failures keep their own error reports, such as kick webhook create message failed.

Tests

  • TestEmbedAbortedByClientIsNotAnError sends a canceled request through LoggingMiddleware and the real /embed handler, with a transport that behaves like http.Client on a canceled context. On main it logs status=502 at error level, matching production. Here it logs 499 at info level.
  • go test -race ./internal/webhook ./internal/publichttp ./cmd passes.

Generated by Claude Code

GET /embed returned 502 in 1.5ms and was reported as an error. The
app's stream preview WebView aborts /embed whenever the preview closes
(iOS loads a blank page to silence audio) or switches channel, and the
Twitch/Kick lookup then fails at once on the canceled request context,
so the handler answers 502.

LoggingMiddleware, which fronts /embed, /metadata, /auth/ and the
webhooks, now records a request whose context was canceled as 499 at
info level, whatever the handler wrote. Webhook persistence failures
keep their own error reports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EzdqAWrbTMdtJutmK41coy
@kevmo314
kevmo314 merged commit 8af17c6 into main Nov 13, 2026
8 checks passed
@kevmo314
kevmo314 deleted the claude/eager-dijkstra-hdrup8 branch November 13, 2026 04:18
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