const wait = (ms: number) => new Promise((res) => setTimeout(res, ms)); export async function callWithRetry(fn: () => Promise, depth = 0): Promise { try { return await fn(); } catch(e: unknown) { if (depth > 5) { throw e; } await wait(2 ** depth * 100); return callWithRetry(fn, depth + 1); } }