Skip to content

fix(radio): Keep recovery from reporting aborted pending loads - #478

Merged
fcastrovilli merged 1 commit into
mainfrom
cursor/radio-27-recovery-reload-abort-8c2f
Nov 7, 2026
Merged

fcastrovilli merged 1 commit into
mainfrom
cursor/radio-27-recovery-reload-abort-8c2f

Conversation

@fcastrovilli

@fcastrovilli fcastrovilli commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

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 → cancelLoad rejects the prior same-generation waitUntilReady with AbortError: Load aborted. MediaElementPlaybackSource.load() treated that as terminal because generation was unchanged.
  • Not covered by fix(radio): Switch stations without false playback errors #457 / RADIO-23/24 on main (7f7ed3b): fix(radio): Switch stations without false playback errors #457 ignores queued media-element abort events and scopes intentional play() 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 AbortError failed because onError received AbortError / Load aborted.
    • Green (after): that test plus a real media error during a pending load still reports onError and the existing recovery / RADIO-23 suites pass (73 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 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.

Open in Web Open in Cursor 

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.

Written for commit f01438c. Summary will update on new commits.

View guided diff Turn on auto-fix

Recovery reloads call loadAttachedSource without bumping generation, so
cancelLoad aborts the still-pending waitUntilReady and the same-generation
AbortError was reported as an unexpected PLAY_ERROR. Track attachment
epochs so a superseded pending load settles without onError, leave resume
to the recovery reload, and keep real media errors visible.

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

Changelog: Recovery no longer reports a false playback failure when it
cancels a stream that was still connecting.

Co-authored-by: Francesco Castrovilli <fcastrovilli@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b25210a-0c3d-4b85-8310-17ae13a0d921
Commits

Reviewing files that changed from the base of the PR and between 7f7ed3b and f01438c.

Files selected for processing: 2

  • apps/radio/src/lib/audio/playback/media-element-playback-source.test.ts
  • apps/radio/src/lib/audio/playback/media-element-playback-source.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T21:47:08.825057Z f01438c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://cursor-radio-27-recovery-reload-abort-8c2f-radio.cwav.workers.dev (commit f01438c)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://59e6bdb0-radio.cwav.workers.dev f01438c 2026-11-07T21:46:48.172Z Visit the dashboard ↗

@fcastrovilli
fcastrovilli merged commit 71cadb0 into main Nov 7, 2026
4 checks passed
@fcastrovilli
fcastrovilli deleted the cursor/radio-27-recovery-reload-abort-8c2f branch November 7, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants