fix(radio): Keep recovery reloads from raising false play errors

Merged
FC
15d ago
+49-4

Summary

Chrome rejects an in-flight play() with AbortError: The play() request was interrupted by a new load request when media is reattached. #457 already scoped pause/stop/cleanup/load() interruptions to playback intent, but recovery still reattached through loadAttachedSource without retiring the in-flight play. That left the same PLAY_ERROR reachable on current main.

 recovery reload
-  reattach via loadAttachedSource only
+  supersede in-flight play intent without clearing resume
+  resume through playForIntent ownership
 active play failures
-  unchanged: AbortError / NotAllowedError / NotSupportedError still report

Fixes RADIO-24
https://avoidquest.sentry.io/issues/RADIO-24

Evidence

  • Root cause: Recovery reloads call loadAttachedSource (not load()), so they skipped cancelPendingPlaybackIntent. An earlier play() stayed current, then Chrome aborted it when recovery called audio.load(), and playForIntent rethrew that AbortError into Single-mode PLAY_ERROR reporting.
  • Already on main (7f7ed3b / #457): station switch, pause, stop, cleanup, and explicit load() no longer raise false play errors. Production events through 2026-11-04 are still tagged radio@0.7.2, which predates that deployable fix for the intentional source-change path.
  • Remaining reachability proved: synthetic fixture with the exact Chrome AbortError message failed before this change when recovery's watchdog reattached during an in-flight play; after the change it settles without entering error.
  • Red → green:
    • Red: a recovery reload does not reject an in-flight play for the same resume intent failed with the Chrome AbortError before the source change.
    • Green: that test plus the existing play-interrupt / active-failure / recovery suites pass (72 tests across playback-source + audio-manager).
  • Validation: bun run check, bun run typecheck, bun run --filter @avoid.quest/radio build, and focused bun test on media-element-playback-source.test.ts + audio-manager.test.ts pass.
  • Not verified: physical Android Chrome against a live Icecast stream; production deploy; Sentry resolution (no Sentry mutation). Build-time Sentry uploads were not exercised.

Overlap

  • RADIO-23 / #457: load-abort / queued media abort and intentional load() play supersession remain there; this PR does not revisit attachment abort listeners.
  • RADIO-27: still about recovery canceling a pending load (AbortError: Load aborted from waitUntilReady). This PR only retires play promises around recovery reattach and does not change load-cancellation reporting.

Merge Danger

Door: two-way

Code-only playback ownership change; no migration or deploy.

Blast Radius: playback

Shared media-element recovery resume for Single, Node, and DJ. Genuine active-intent play failures remain visible; only superseded in-flight plays are settled.

Open in Web Open in Cursor 

Summary by cubic

Recovery reloads no longer raise false playback errors when a stream was already trying to play. Recovery reattaches media through loadAttachedSource without load(), so an in-flight play() stayed current and Chrome rejected it with an AbortError once the element reloaded. Recovery now supersedes that play intent before reattaching and routes resume through the same ownership check that already covers pause, stop, cleanup, and explicit load(). Genuine play failures like NotAllowedError and NotSupportedError still report.