Update retry logic for audio and images#13768
Conversation
|
| /** | ||
| * Returns timeout in ms for audio load attempts, with exponential backoff on retries. | ||
| */ | ||
| export const getAudioLoadTimeoutMs = (retries: number): number => |
There was a problem hiding this comment.
maybe doesn't belong in "constants.ts"
| this.audio.preload = 'none' | ||
| this.audio.crossOrigin = 'anonymous' | ||
| this.audio.src = mp3Url | ||
| const loadTimeoutMs = timeoutMs ?? getAudioLoadTimeoutMs(0) |
There was a problem hiding this comment.
i think maybe default to no timeout instead?
| shouldPreview, | ||
| retries ?? 0 | ||
| ) | ||
| const streamObj = shouldPreview ? track.preview : track.stream |
|
|
||
| type StreamObject = { url?: string; mirrors?: string[] } | ||
|
|
||
| const tryUrl = async (url: string, timeoutMs: number): Promise<boolean> => { |
There was a problem hiding this comment.
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?
| const [primary, ...mirrors] = urlsToTry | ||
| const primaryFallback = primary ?? null | ||
|
|
||
| // Phase 1: Try primary with 2s |
There was a problem hiding this comment.
I think this logic isn't quite right, we should retry the primary too with bigger timeouts
No description provided.