fix(media): MediaClient's retry backoff works outside Bun

Bun.sleep threw in a browser or Node the first time a piece was retried;
setTimeout does the same everywhere. The browser bundle has no Bun.* left.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-19 00:37:09 +02:00
parent 65d7a0646f
commit 8d6f1fb8a6
2 changed files with 5 additions and 1 deletions

View File

@@ -50,7 +50,8 @@ const MAX_TRIES = 8;
/** The relay is restarting, overloaded or the network dropped: try again. */
class Transient extends Error {}
const backoff = (attempt: number) => Bun.sleep(Math.min(30_000, 500 * 2 ** attempt));
// setTimeout, not Bun.sleep: the client runs in browsers and Node too.
const backoff = (attempt: number) => new Promise<void>((r) => setTimeout(r, Math.min(30_000, 500 * 2 ** attempt)));
export class MediaClient {
private readonly fetchFn: typeof fetch;