Skip to content

Commit

Permalink
Gracefully fail on block network issue for legacy events
Browse files Browse the repository at this point in the history
  • Loading branch information
Ktl-XV committed Jul 3, 2023
1 parent 587b296 commit 5811e36
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/scripts/utils/event_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ export class PullAndSaveEvents {
getterFunction: (startBlockNumber: number, endBlock: number) => Promise<LogWithDecodedArgs<ARGS>[] | null>,
parser: (decodedLog: LogWithDecodedArgs<ARGS>) => EVENT,
): Promise<void> {
const { startBlockNumber, hasLatestBlockChanged } = await getStartBlockAsync(
eventName,
connection,
web3Source,
currentBlock,
FIRST_SEARCH_BLOCK,
);
let startBlockResponse;
try {
startBlockResponse = await getStartBlockAsync(
eventName,
connection,
web3Source,
currentBlock,
FIRST_SEARCH_BLOCK,
);
} catch (err) {
logger.error(`${err}, trying next time`);
return;
}
const { startBlockNumber, hasLatestBlockChanged } = startBlockResponse;

if (!hasLatestBlockChanged) {
logger.debug(`No new blocks to scan for ${eventName}, skipping`);
Expand Down

0 comments on commit 5811e36

Please sign in to comment.