File size: 464 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// eslint-disable-next-line import/no-extraneous-dependencies
// @ts-expect-error File exists
import asyncRetry from 'next/dist/compiled/async-retry'
export async function retry<T>(
fn: asyncRetry.RetryFunction<T>,
retries: number
) {
return await asyncRetry(fn, {
retries,
onRetry(e: unknown, attempt: unknown) {
console.error(
(e as Error).message + `\n\nRetrying ${attempt}/${retries}...`
)
},
minTimeout: 100,
})
}
|