feat(worker): enhance error recovery and panic handling across worker routines#61
Open
feat(worker): enhance error recovery and panic handling across worker routines#61
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a regular-worker crash on EVM/BTC when a batch contains a failed/missing block followed by a valid block, and add panic containment for long-lived worker goroutines.
Problem
The regular worker could panic on this path:
GetBlocks(...)returns a batch where blockNis missing or erroredN+1is still present in the same batchNbecauseres.Block == nil || res.Error != nilresults[i-1]checkContinuity(results[i-1], res)dereferences a nil previous block and crashes the workerThis was especially visible with transient RPC issues such as rate limits / quota errors.
Separately, long-lived worker goroutines did not consistently recover from panics, so a panic could crash the whole indexer process.
Changes
Regular worker
Indexer.GetBlock(...)2attempts1sdelay between attemptscurrentBlockacross a contiguous recovered prefixContinuity safety
prev.Blockwhen the previous batch entry is missing/erroredPanic containment
BaseWorker.run()jobs into returned errors so they flow through the existing retry pathWhy this approach
GetBlock(...)path for provider rotation instead of adding custom RPC failover logic in the workerTests
Added/updated worker tests to cover:
Notes