Skip to content

Commit

Permalink
chore(retry): remove recurrsion
Browse files Browse the repository at this point in the history
  • Loading branch information
D4mph1r committed Sep 12, 2024
1 parent 3d7018e commit 54147cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
10 changes: 0 additions & 10 deletions src/handler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ export async function listenEvents(
}

async function processEvent(chain: THandler, ev: LockEvent) {
log.info(
"--------------------------------------",
ev.transactionHash,
"--------------------------------------",
);
const sourceChain = map.get(ev.sourceChain as TSupportedChains);
if (!sourceChain) {
log.warn(
Expand Down Expand Up @@ -177,11 +172,6 @@ export async function listenEvents(
log.info(
`Approved and Signed Data for ${inft.transactionHash} on ${sourceChain.chainIdent} at TX: ${approved?.hash}`,
);
log.info(
"--------------------------------------",
ev.transactionHash,
"--------------------------------------",
);
}

async function poolEvents(chain: THandler) {
Expand Down
15 changes: 9 additions & 6 deletions src/handler/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ export async function retry<T>(
ctx: string,
log: LogInstance,
): Promise<T> {
try {
return await func();
} catch (err) {
log.info(`Context: ${ctx} - Retrying. Error:`, err);
await setTimeout(5000);
return retry(func, ctx, log);
while (true) {
try {
const res = await func();
return res; // Only returns once the function succeeds
} catch (err) {
log.info(`Context: ${ctx} - Retrying. Error:`, err);
// Use a Promise-based delay
await setTimeout(5000);
}
}
}

Expand Down

0 comments on commit 54147cb

Please sign in to comment.