|
|
|
@ -280,13 +280,14 @@ export function prettyPrintPuppeteerAssertionError(message) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function retryAsync<T>(fn: () => Promise<T>, maxAttempts: number = 3): Promise<T> {
|
|
|
|
export async function retryAsync<T>(fn: () => Promise<T>, maxAttempts: number = 3, interval: number = 1000): Promise<T> {
|
|
|
|
let attempts = 0;
|
|
|
|
let attempts = 0;
|
|
|
|
while (attempts <= maxAttempts) {
|
|
|
|
while (attempts <= maxAttempts) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return await fn();
|
|
|
|
return await fn();
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
if (++attempts >= maxAttempts) throw err;
|
|
|
|
if (++attempts >= maxAttempts) throw err;
|
|
|
|
|
|
|
|
new Promise(resolve => setTimeout(resolve, interval));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|