fix(radio): Preserve mode-lifecycle error causes for Sentry

Merged
FC
15d ago
+234-23

Summary

Diagnostic fix for RADIO-26 (operation=loadModeLifecycle, generic AppError / UNEXPECTED_ERROR, no mode tag, empty breadcrumbs, radio@0.7.2, Firefox desktop, 2026-10-30).

This does not claim to resolve the original production failure. The captured event lost the underlying rejection, so the incident cause remains unknown. This PR only makes the same failure shape diagnosable next time and locks in regression coverage.

What RADIO-26 shows

  • Stack is the Radios effect catch around dynamic mode-lifecycle-requests import + synchronizeMode, then captureError → toAppError → AppError.
  • Tags: operation=loadModeLifecycle, surface=ui, no mode tag → import-failure path, not synchronizeMode’s reportFailure (which always tags mode).
  • Reported value is the generic safe message, so the original rejection was not an Error (or was already a cause-less AppError); captureError only forwarded cause instanceof Error to Sentry.

What is reproducible today

PathBehavior beforeAfter
Non-Error rejection into captureErrorSentry gets only generic AppErrorPromoted NonErrorRejection Error with safe summary + original on cause
Lifecycle module load failureloadModeLifecycle without modeSame operation, mode tagged
Synthetic synchronizeMode activation rejectionAlready owned by synchronizeMode + modeUnchanged (regression proves ownership)

No functional playback/orchestration bug was demonstrated from the single production event; stream/provider issues are out of scope.

Red → green

Red (before implementation):

  • reporting policy > reports a non-Error rejection as a reportable Error that keeps the cause
  • reporting policy > does not put object rejection bodies into the reportable Error message
  • runModeLifecycleSynchronization > tags mode when the lifecycle module fails to load
  • (pass already) synthetic synchronizeMode rejection keeps operation=synchronizeMode

Green after the changes: those three + full suites below.

Changed files

  • packages/error/src/index.ts — promote non-Error causes for Sentry without JSON-serializing objects
  • packages/error/src/index.test.ts — RADIO-26-shaped capture regressions
  • apps/radio/src/lib/mode-lifecycle-boot.ts — extract load+sync with mode-tagged import failures
  • apps/radio/src/lib/mode-lifecycle-boot.test.ts — import vs synchronizeMode ownership
  • apps/radio/src/components/radio/index.tsx — use the boot helper

Validation

  • bun run check
  • bun run typecheck
  • bun run --filter @avoid.quest/error test
  • bun test packages/error/src/index.test.ts apps/radio/src/lib/mode-lifecycle-boot.test.ts apps/radio/src/lib/mode-lifecycle-requests.test.ts

Not verified: reproducing the exact Firefox 0.7.2 production rejection value (unavailable from the event).

Base: 7f7ed3bf52672df71a5514591af0b3a866708d0b

Not using Fixes RADIO-26 — observability only; original incident unexplained.

Open in Web Open in Cursor 

Summary by cubic

Makes mode-lifecycle load failures diagnosable in Sentry by preserving non-Error rejection causes and tagging the mode on import failures, without claiming to fix the original production incident (RADIO-26).

  • Non-Error rejections are promoted to a NonErrorRejection Error for reporting, keeping the original value on cause; object bodies are summarized as "Object" to avoid leaking private data.
  • loadModeLifecycle errors now carry a mode tag; synchronizeMode keeps ownership of its own failure reporting.