fix(studio): a cancelled media read is not retried or logged as a failed fetch (#8589)

This commit is contained in:
Miguel Ángel
2026-11-23 13:46:42 +00:00
committed by GitHub
parent 5409387218
commit 112e52c3c5
2 changed files with 7 additions and 0 deletions
@@ -51,6 +51,12 @@ describe("mediaUrlSourceOptions", () => {
await expect(mediaUrlSourceOptions("probe").fetchFn(URL_WITH_PATH)).rejects.toBe(abort);
});
it("never retries a read that was cancelled, so a cancel is not logged as a failed fetch", () => {
const { getRetryDelay } = mediaUrlSourceOptions("probe");
expect(getRetryDelay(1, new DOMException("Media reads cancelled", "AbortError"))).toBeNull();
});
it("retries a network failure twice, then gives up and records the retries", () => {
const { getRetryDelay } = mediaUrlSourceOptions("probe");
const failure = new MediaFetchError("probe", null, "TypeError");
@@ -194,6 +194,7 @@ export function mediaUrlSourceOptions(reader: MediaReader) {
return typedResponse(response, asked, request);
};
const getRetryDelay = (_previousAttempts: number, error: unknown): number | null => {
if (isAbort(error)) return null;
const start = error instanceof MediaFetchError ? error.start : null;
const failed = failuresByStart.get(start) ?? 0;
const clientError =