fix(radio): Switch stations without false playback errors
Summary
Switching or stopping playback can leave browser tasks from the previous request in flight. A queued media abort rejected the replacement load; already-loaded playback and the readiness retry could also reject after their playback intent was canceled.
load a replacement stream
- reject on any media abort event
+ cancel only through this attachment's AbortController
+ retain media errors and readiness timeout
play or retry after readiness
- propagate a rejection from an obsolete request
+ propagate only while that playback intent still owns the element
Fixes RADIO-23
Fixes RADIO-24
Changelog: Switching or stopping playback no longer causes false playback failures from the previous request.
Evidence
- Before: synthetic source tests reproduced a queued abort failing a replacement load, interruptions after pause/stop/cleanup/load, and cancellation during the readiness retry.
After: the regression tests pass; active AbortError, permission and format failures still reject, and media errors/timeouts remain reported. Manager tests verify a paused start or renewal stays paused after an abort followed by readiness. - Validation:
bun run check,bun run typecheck, andbun run --filter @avoid.quest/radio buildpass. The focused playback/input/manager suites pass (79 tests).bun run --filter @avoid.quest/radio testhas 3,551 passes and one preexisting failure:deck-progress-isolation.test.tsxexpects transport render commits to increase. Unmodified main (f0c5c33) reproduces the same sole failure with 3,540 passes; the failing test passes in isolation. - Sentry events and breadcrumbs were checked against source; the linked traces contain no spans or logs, so the original production interactions cannot be replayed exactly. No raw event fixtures were added. Physical-device playback and production deployment are unverified. Build-time Sentry uploads were skipped because upload credentials were absent.
Assigned format issues were investigated separately and are not closed by this PR:
- RADIO-22: 12 RadioJar events are covered by #456 (
f0c5c33), merged after the latest event. The retired Alhara URL still returns 404; its replacement returns HTTP 200audio/mpeg, and the persisted-URL regression passes. The other events are one BlackOut and one NTS failure on Android. BlackOut and both current NTS URLs return HTTP 200 audio now; there is insufficient evidence to reproduce or claim those historical failures fixed. - RADIO-1Z: its RadioJar event is likewise covered by #456. Its remaining SoundCloud event is from 0.7.0 on October 7, before #422 (
5f62eb9, October 10) restricted native HLS to WebKit. The existing Chromium/SoundCloud regression passes on main. This matches the earlier fix, but the original signed media and browser session cannot be replayed from the available event.
Merge Danger
Door: two-way
A code-only change with no migration or deployment changes.
Blast Radius: playback
Shared media-element loading and playback in Single, Node and DJ. A bare browser abort without an application cancellation now waits for a media error or the existing 20-second readiness timeout; real current-request failures remain visible.
Summary by cubic
Switching or stopping playback no longer triggers false playback errors from the previous request. Previously, a queued media abort event could reject a replacement load, and obsolete play promises could reject after pause, stop, or a new load. Now cancellation is scoped to the current attachment via its AbortController, and play rejections are only propagated while the initiating playback intent still owns the element. Media errors and the readiness timeout are still reported.
Regression tests cover queued aborts, interrupted plays, and retry cancellation, and confirm an active post-readiness retry still surfaces its rejection. The deck transport test now uses the real provider instead of a module mock so progress sampling is not disabled for later tests. Fixes RADIO-23 and RADIO-24.
Summary by CodeRabbit
- Bug Fixes
- Improved playback reliability when media is replaced or playback is paused, stopped, or canceled during startup.
- Queued abort events no longer prevent playback setup from completing or cause playback to resume unexpectedly.
- Genuine playback errors and readiness timeouts continue to be reported when they occur.