Clarify code

This commit is contained in:
Eric Bailey
2025-06-09 13:42:29 -05:00
parent c95aea5635
commit f1af01655b
+4 -5
View File
@@ -3,18 +3,17 @@ import {isNetworkError} from '#/lib/strings/errors'
export async function retry<P>(
retries: number,
cond: (err: any) => boolean,
fn: () => Promise<P>,
shouldRetry: (err: any) => boolean,
action: () => Promise<P>,
delay?: number,
): Promise<P> {
let lastErr
while (retries > 0) {
try {
return await fn()
return await action()
} catch (e: any) {
lastErr = e
// should retry?
if (cond(e)) {
if (shouldRetry(e)) {
if (delay) {
await timeout(delay)
}