Skip to content

Update retry logic for audio and images#13768

Merged
dylanjeffers merged 8 commits intomainfrom
add-playback-timeout
Feb 25, 2026
Merged

Update retry logic for audio and images#13768
dylanjeffers merged 8 commits intomainfrom
add-playback-timeout

Conversation

@dylanjeffers
Copy link
Contributor

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2026

⚠️ No Changeset found

Latest commit: b0d3e1d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dylanjeffers dylanjeffers changed the title Add 5s pending playback timeout Add audio timeout with backoff Feb 25, 2026
@pull-request-size pull-request-size bot added size/L and removed size/S labels Feb 25, 2026
/**
* Returns timeout in ms for audio load attempts, with exponential backoff on retries.
*/
export const getAudioLoadTimeoutMs = (retries: number): number =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe doesn't belong in "constants.ts"

this.audio.preload = 'none'
this.audio.crossOrigin = 'anonymous'
this.audio.src = mp3Url
const loadTimeoutMs = timeoutMs ?? getAudioLoadTimeoutMs(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think maybe default to no timeout instead?

shouldPreview,
retries ?? 0
)
const streamObj = shouldPreview ? track.preview : track.stream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this changing?


type StreamObject = { url?: string; mirrors?: string[] }

const tryUrl = async (url: string, timeoutMs: number): Promise<boolean> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused, doesn't the audioPlayer handle the timeouts? why separately fetch?

i could see an argument for trying all mirrors in parallel, but that's not what's happening here?

@dylanjeffers dylanjeffers changed the title Add audio timeout with backoff Update retry logic for audio and images Feb 25, 2026
const [primary, ...mirrors] = urlsToTry
const primaryFallback = primary ?? null

// Phase 1: Try primary with 2s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic isn't quite right, we should retry the primary too with bigger timeouts

@dylanjeffers dylanjeffers merged commit e19ec94 into main Feb 25, 2026
12 checks passed
@dylanjeffers dylanjeffers deleted the add-playback-timeout branch February 25, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants