diff --git a/packages/cli/src/job-runner.ts b/packages/cli/src/job-runner.ts index 959ddd2f4..1845cffca 100644 --- a/packages/cli/src/job-runner.ts +++ b/packages/cli/src/job-runner.ts @@ -111,6 +111,7 @@ export class JobRunnerCmd { // Delete all active and pending (before completed) jobs to start job-runner without old queued jobs await jobRunner.jobQueue.deleteAllJobs('completed'); await jobRunner.resetToPrevIndexedBlock(); + await indexer.updateSyncStatusIndexingError(false); await startJobRunner(jobRunner); jobRunner.handleShutdown(); diff --git a/packages/util/src/indexer.ts b/packages/util/src/indexer.ts index d98d03a29..d16ca53cd 100644 --- a/packages/util/src/indexer.ts +++ b/packages/util/src/indexer.ts @@ -148,16 +148,15 @@ export class Indexer { if (block.hash) { resultBlock = await this.getBlockProgress(block.hash); - } else if (block.number) { - // Get all the blocks at the given height - const blocksAtHeight = await this.getBlocksAtHeight(block.number, false); + } else { + const blockHeight = block.number ? block.number : syncStatus.latestIndexedBlockNumber - 1; + + // Get all the blocks at a height + const blocksAtHeight = await this.getBlocksAtHeight(blockHeight, false); if (blocksAtHeight.length) { resultBlock = blocksAtHeight[0]; } - } else { - resultBlock = await this.getBlockProgress(syncStatus.latestIndexedBlockHash); - assert(resultBlock); } return resultBlock diff --git a/packages/util/src/job-runner.ts b/packages/util/src/job-runner.ts index 291a88c3a..61f1595b8 100644 --- a/packages/util/src/job-runner.ts +++ b/packages/util/src/job-runner.ts @@ -624,12 +624,12 @@ export class JobRunner { log(`Retrying event processing after ${EVENTS_PROCESSING_RETRY_WAIT} ms`); await wait(EVENTS_PROCESSING_RETRY_WAIT); - // TODO: Stop next job in queue from processing next + // TODO: Stop job for next block in queue (in historical processing) - const eventsProcessingRetrytJob: EventsJobData = { ...jobData, isRetryAttempt: true }; + const eventsProcessingRetryJob: EventsJobData = { ...jobData, isRetryAttempt: true }; await this.jobQueue.pushJob( QUEUE_EVENT_PROCESSING, - eventsProcessingRetrytJob, + eventsProcessingRetryJob, { priority: 1 } ); }