fix(relay): filter client-abandoned WS upgrade errors from Sentry

Merged
SA
4mo ago
+6-2

Summary

RELAY-5 (TypeError: upgrade requires a Request object, 515 occurrences since June) is a client-gone race, not a relay fault:

  1. A WS upgrade request hits the relay; the auth middleware awaits JWT verification + checkHostAccess (network round-trips) before @hono/node-ws completes the handshake.
  2. The client disconnects during that window.
  3. Bun's node:ws shim (completeUpgrade) then calls server.upgrade(socket[kBunInternals], …), but the underlying Bun Request was released with the connection — server.upgrade(undefined) throws, surfacing as an unhandled rejection.

The client is gone either way, so this drops the event in beforeSend alongside the TunnelLifecycleError churn filter added in #6080. The process already survives these via the suppressed unhandledRejection handler; this just stops the Sentry noise.

Fixes RELAY-5

Test plan

  • bun run lint clean, relay typecheck clean
  • After merge (relay auto-deploys on main): confirm RELAY-5 stops receiving events

https://claude.ai/code/session_012u6VZtfQgoTh8qS4NqCb7e


Summary by cubic

Filters client-abandoned WebSocket upgrade errors from Sentry in the relay to reduce noise. Fixes RELAY-5.

  • Bug Fixes
    • Ignore node:ws "upgrade requires a Request object" exceptions in Sentry beforeSend, which happen when clients disconnect during async JWT/host access checks before the @hono/node-ws handshake completes.

Summary by CodeRabbit

  • Bug Fixes
    • Reduced unnecessary error reports by filtering out known upgrade-related errors.
    • Continued suppressing expected tunnel lifecycle errors from error monitoring.