Skip to content

Commit

Permalink
feat(retry): remove retry limit
Browse files Browse the repository at this point in the history
  • Loading branch information
imsk17 committed Sep 12, 2024
1 parent 3e28915 commit 7c714dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/handler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ export async function listenEvents(
approvalFn,
`Approving transfer ${JSON.stringify(inft, null, 2)}`,
log,
3,
);

log.info(
Expand Down Expand Up @@ -268,7 +267,6 @@ export async function listenStakeEvents(
approvalFn,
`Approving stake ${JSON.stringify(ev, null, 2)}`,
log,
6,
);
log.info(
approved
Expand Down
10 changes: 3 additions & 7 deletions src/handler/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,13 @@ export async function retry<T>(
func: () => Promise<T>,
ctx: string,
log: LogInstance,
retries = 3,
): Promise<T> {
try {
return await func();
} catch (err) {
if (retries === 0) {
throw err;
}
log.info(`Context: ${ctx} - Retrying ${retries} more times. Error: ${err}`);
await setTimeout(6000 * (3 - retries));
return retry(func, ctx, log, retries - 1);
log.info(`Context: ${ctx} - Retrying. Error:`, err);
await setTimeout(5000);
return retry(func, ctx, log);
}
}

Expand Down

0 comments on commit 7c714dd

Please sign in to comment.