async function retry(fn, attempts = 5, base = 300) { for (let n = 0; n < attempts; n++) { try { return await fn(); } catch (err) { if (n === attempts - 1) throw err; const wait = base * 2 ** n + Math.random() * 100; await new Promise((r) => setTimeout(r, wait)); } } }