From 26c1debb7affba4464d083acb298b93d4838df28 Mon Sep 17 00:00:00 2001 From: JonnyBurger Date: Tue, 30 Sep 2025 15:03:29 +0200 Subject: [PATCH] Update docs for getRetryDelay() --- docs/guide/reading-media-files.md | 6 ++++-- src/source.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/guide/reading-media-files.md b/docs/guide/reading-media-files.md index 3e2433e..f8f2ae2 100644 --- a/docs/guide/reading-media-files.md +++ b/docs/guide/reading-media-files.md @@ -487,7 +487,7 @@ If you're using this source in the browser and the URL is on a different origin, ```ts type UrlSourceOptions = { requestInit?: RequestInit; - getRetryDelay?: (previousAttempts: number) => number | null; + getRetryDelay?: (previousAttempts: number, error: unknown, url: string | URL | Request) => number | null; // The maximum number of bytes the cache is allowed to hold // in memory. Defaults to 8 MiB. @@ -517,7 +517,9 @@ const source = new UrlSource('https://example.com/bigbuckbunny.mp4', { }); ``` -Not setting `getRetryDelay` will default to an infinite, capped exponential backoff pattern. If a CORS error is suspected (`fetch()` did reject even though `navigator.onLine` is true), no further retries will be made. +Not setting `getRetryDelay` will lead to the default being used: +- infinite exponential backoff pattern, capped at 16 seconds. +- If a CORS error is suspected (`fetch()` did reject even though `navigator.onLine` is true and origin is different), no further retries will be made. --- diff --git a/src/source.ts b/src/source.ts index dbbd105..1c048aa 100644 --- a/src/source.ts +++ b/src/source.ts @@ -306,7 +306,7 @@ export type UrlSourceOptions = { * failed. If the function returns `null`, no more retries will be made. * * By default, it uses an exponential backoff algorithm that never gives up unless - * a CORS error is suspected (`fetch()` did reject even though `navigator.onLine` is true) + * a CORS error is suspected (`fetch()` did reject, `navigator.onLine` is true and origin is different) */ getRetryDelay?: (previousAttempts: number, error: unknown, url: string | URL | Request) => number | null;