Skip to content

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

Merged
fcastrovilli merged 1 commit into
mainfrom
cursor/radio-24-play-load-race-b786
Nov 7, 2026
Merged

fcastrovilli merged 1 commit into
mainfrom
cursor/radio-24-play-load-race-b786

Conversation

@fcastrovilli

@fcastrovilli fcastrovilli commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

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 / fix(radio): Switch stations without false playback errors #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 / fix(radio): Switch stations without false playback errors #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.

Written for commit 7a70776. Summary will update on new commits.

View guided diff Turn on auto-fix

Recovery reattaches media through loadAttachedSource without load(), so
an in-flight play() could still reject with Chrome's AbortError when the
element loaded again. Supersede that play intent without clearing resume,
and route recovery resume through the same ownership check.

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

Changelog: Recovery no longer reports a false playback failure when it
reloads a stream that was already trying to play.

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 56 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: 45d4adc9-2b34-4c86-aff7-b43f9d929b80
Commits

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

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:42:27.090280Z 7a70776 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-24-play-load-race-b786-radio.cwav.workers.dev (commit 7a70776)

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://9c9b91b1-radio.cwav.workers.dev 7a70776 2026-11-07T21:42:51.474Z Visit the dashboard ↗

@fcastrovilli
fcastrovilli merged commit 2d95d32 into main Nov 7, 2026
4 checks passed
@fcastrovilli
fcastrovilli deleted the cursor/radio-24-play-load-race-b786 branch November 7, 2026 23:31
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