Statement
Write retry(fn, { retries, baseMs }, sleep). Call fn; if it fails, wait with await sleep(ms) and try again, up to retries retries. Waits are baseMs, baseMs*2, baseMs*4… Return the first successful result or, when retries run out, reject with the last error. sleep is a parameter so it can be tested without really waiting.