export const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); export const runWithRetries = async ( fn: () => Promise, retries: number, backoff: number = 2000 ): Promise => { let attempts = 0; while (true) { await wait(attempts * backoff); try { return await fn(); } catch (e) { if (attempts >= retries) { throw e; } console.error("Error:", e); attempts++; } } };