Skip to content
Type

UrlSourceOptions ​

Options for UrlSource.

ts
type UrlSourceOptions = {
	requestInit?: Omit<RequestInit, 'signal'>;
	getRetryDelay?: (previousAttempts: number, error: unknown, url: string | URL | Request) => number | null;
	maxCacheSize?: number;
	parallelism?: number;
	fetchFn?: typeof fetch;
	handleUnhandledError?: (error: unknown) => unknown;
};

Used by ​

Properties ​

requestInit ​

ts
requestInit?: Omit<RequestInit, 'signal'>;

The RequestInit used by the Fetch API. Can be used to further control the requests, such as setting custom headers.

The signal field is not available, as Mediabunny controls request cancellation internally. If you want to cancel ongoing requests, use Input.dispose.

getRetryDelay ​

ts
getRetryDelay?: (previousAttempts: number, error: unknown, url: string | URL | Request) => number | null;

A function that returns the delay (in seconds) before retrying a failed request. The function is called with the number of previous, unsuccessful attempts, as well as with the error with which the previous request 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, navigator.onLine is true and origin is different).

maxCacheSize ​

ts
maxCacheSize?: number;

The maximum number of bytes the cache is allowed to hold in memory. Defaults to 64 MiB.

parallelism ​

ts
parallelism?: number;

The maximum number of parallel requests to use for fetching. Defaults to 2.

fetchFn ​

ts
fetchFn?: typeof fetch;

A WHATWG-compatible fetch function. You can use this field to polyfill the fetch function, add missing features, or use a custom implementation.

handleUnhandledError ​

ts
handleUnhandledError?: (error: unknown) => unknown;

Handles errors that occur while no read is pending. By default, these become unhandled rejections.

Released under the Mozilla Public License 2.0.