Skip to content

Backend Indexer: Handle missed ledgers on startup#382

Open
Godfrey-Delight wants to merge 7 commits into
BCPathway:mainfrom
Godfrey-Delight:feat/indexer-gap-detection-on-startup
Open

Backend Indexer: Handle missed ledgers on startup#382
Godfrey-Delight wants to merge 7 commits into
BCPathway:mainfrom
Godfrey-Delight:feat/indexer-gap-detection-on-startup

Conversation

@Godfrey-Delight

@Godfrey-Delight Godfrey-Delight commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Added detectGap() integrated into runIndexer's startup path to detect and handle missed ledgers. On first run, defaults to ledger 1 instead of the invalid 0. Logs a warning when the gap exceeds 100 ledgers, and resets to the current ledger if the stored value is somehow ahead of the network. Also fixed a pre-existing bug where startLedger = 0 was passed to Soroban RPC on first run, and resolved TypeScript type mismatches with the v11 Stellar SDK (txHash property, event type). 23 unit/integration tests cover all gap detection edge cases, RPC/Prisma error propagation, error recovery in the event loop, and the stored-ahead-of-network reset scenario.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • CI
  • Chore

Checklist

  • I ran pre-commit run --all-files locally and it passed
  • All CI jobs pass on this branch
  • I added or updated tests for new behaviour
  • I updated relevant docs / comments
  • No secrets or credentials are included
  • No breaking changes to public APIs (or I've documented them)

Breaking changes?

No

Related issues

Closes #303

Added detectGap() integrated into runIndexer's startup path to detect and handle missed ledgers. On first run, defaults to ledger 1 instead of the invalid 0. Logs a warning when the gap exceeds 100 ledgers, and resets to the current ledger if the stored value is somehow ahead of the network. Also fixed a pre-existing bug where startLedger = 0 was passed to Soroban RPC on first run, and resolved TypeScript type mismatches with the v11 Stellar SDK (txHash property, event type). 23 unit/integration tests cover all gap detection edge cases, RPC/Prisma error propagation, error recovery in the event loop, and the stored-ahead-of-network reset scenario.
@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Godfrey-Delight Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend Indexer: Handle missed ledgers on startup (gap detection)

1 participant