fix(radio): Keep recovery from reporting aborted pending loads
Summary
Recovery's watchdog reload calls loadAttachedSource without bumping generation. That cancelLoad()-aborts a still-pending waitUntilReady, and the same-generation AbortError: Load aborted was reported as an unexpected PLAY_ERROR (RADIO-27 on radio@0.7.2, Firefox, single-mode Icecast).
recovery reload while load() still pending
- cancelLoad → AbortError → onError / PLAY_ERROR
+ attachment epoch supersedes the pending waiter
+ settle without onError; recovery owns resume
real media errors during pending load
- unchanged: still report through onError
Fixes RADIO-27
https://avoidquest.sentry.io/issues/RADIO-27
Evidence
- Root cause:
scheduleReload→reload→loadAttachedSource→attachment.load→cancelLoadrejects the prior same-generationwaitUntilReadywithAbortError: Load aborted.MediaElementPlaybackSource.load()treated that as terminal because generation was unchanged. - Not covered by #457 / RADIO-23/24 on main (
7f7ed3b): #457 ignores queued media-elementabortevents and scopes intentionalplay()supersession for pause/stop/cleanup/load(). It does not treat recovery's controller abort of a pending same-generation attachment as expected cancellation. - Red → green (TDD):
- Red (before source change):
recovery reload canceling a pending load does not report AbortErrorfailed becauseonErrorreceivedAbortError/Load aborted. - Green (after): that test plus
a real media error during a pending load still reports onErrorand the existing recovery / RADIO-23 suites pass (73 tests across playback-source + audio-manager).
- Red (before source change):
- Validation:
bun run check,bun run typecheck,bun run --filter @avoid.quest/radio build, and focusedbun testonmedia-element-playback-source.test.ts+audio-manager.test.tspass. - Not verified: physical Firefox against a live Icecast stream; production deploy; Sentry resolution (no Sentry mutation).
Overlap / composability
| PR | Scope | Shared files | Conflict risk |
|---|---|---|---|
| #457 (merged) | Queued media abort + intentional play supersession (RADIO-23/24 station-switch path) | same playback files historically | Already on base 7f7ed3b |
| #475 (open) | Recovery reattach supersedes in-flight play intent; resume via playForIntent (Chrome play() interrupted by new load) | media-element-playback-source.ts / .test.ts | Low / two-way door |
| This PR | Recovery cancel of pending load / waitUntilReady AbortError reporting (RADIO-27) | same two files | Low / two-way door |
#475 does not change pending-load cancellation or onError reporting. This PR does not add supersedeInFlightPlay, does not re-route recovery resume through playForIntent, and does not duplicate that play-intent fix. The only adjacent play() change here is: after a superseded pending load() settles, if recovery is still reloading, leave resume to recovery instead of racing a second play(). That is load-generation ownership, not play-intent invalidation.
Expected merge: either order works. Text conflicts are likely around loadAttachedSource (this PR) vs recovery reload/resume wrappers (#475) and separately added tests in the same describe block.
Merge Danger
Door: two-way
Code-only playback ownership change; no migration or deploy.
Blast Radius: playback
Shared media-element recovery for Single, Node, and DJ. Genuine pending-load media errors remain visible; only same-generation recovery cancellations of superseded attachments are settled.


Summary by cubic
Fixes recovery's reload canceling a still-pending load so it no longer reports a false PLAY_ERROR (RADIO-27). Tracks an attachment epoch so a superseded pending load settles silently and recovery owns resume, while genuine media errors during a pending load still reach onError.