export { autoRetry } import { TIMEOUT_AUTORETRY } from './TIMEOUTS.js' import { sleep } from './utils.js' async function autoRetry( test: () => Result | Promise, { timeout = TIMEOUT_AUTORETRY }: { timeout?: number } = {}, ): Promise { const period = 100 const numberOfTries = timeout / period let i = 0 while (true) { try { return await test() } catch (err) { i = i + 1 if (i > numberOfTries) { throw err } } await sleep(period) } }