feat: add timeout
This commit is contained in:
parent
ce0497c083
commit
132a13a140
2
dist/setup/index.js
generated
vendored
2
dist/setup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
10
src/utils.ts
10
src/utils.ts
@ -1,8 +1,14 @@
|
||||
export function retry<T>(fn: () => Promise<T>, retries: number): Promise<T> {
|
||||
export function retry<T>(
|
||||
fn: () => Promise<T>,
|
||||
retries: number,
|
||||
timeout = 5000
|
||||
): Promise<T> {
|
||||
return fn().catch((err) => {
|
||||
if (retries <= 0) {
|
||||
throw err;
|
||||
}
|
||||
return retry(fn, retries - 1);
|
||||
return new Promise((resolve) => setTimeout(resolve, timeout)).then(() =>
|
||||
retry(fn, retries - 1, timeout)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user