Skip to content

fix(indexer): mark reads stale and surface per-network status when indexer is unconfigured (#238) - #252

Open
Stanley471 wants to merge 1 commit into
Miracle656:mainfrom
Stanley471:fix/issue-238-mainnet-indexer-staleness
Open

Stanley471 wants to merge 1 commit into
Miracle656:mainfrom
Stanley471:fix/issue-238-mainnet-indexer-staleness

Conversation

@Stanley471

Copy link
Copy Markdown

Closes #238

Summary of Changes

  1. Explicit Staleness Marking on Unconfigured/Stopped Networks:

    • In \src/api.ts, the stale read middleware now checks whether the network's indexer is stopped or unconfigured via \isIndexerStopped(net)\ alongside \checkRpcHealth(net).
    • When the indexer loop for a network is not running, read responses serve whatever data is in the database with explicit staleness headers and body attributes:
      • Header: \X-Data-Stale: true, \X-Indexer-Running: false, and \X-As-Of-Ledger: .
      • JSON body: \stale: true, \indexer_running: false, and \�s_of_ledger: .
    • Rationale for Answering with Explicit Staleness Markers: Answering with an explicit staleness marker rather than refusing outright is essential so existing clients, dashboards, and wallet history views can still display previous historical transactions rather than encountering hard 500/503 errors or receiving an empty list that masquerades as zero transactions. The presence of \stale: true\ and \indexer_running: false\ allows callers and dashboards to unmistakably distinguish 'no transfers' from 'indexer stopped/unconfigured'.
  2. **Per-Network Indexer State in /status**:

    • Track per-network indexer status in \src/indexer.ts\ (
      unningNetworks, \isIndexerRunning, \isIndexerStopped, \getIndexerUnstartedReason).
    • In \src/api.ts, the /status\ endpoint now reports every enabled network in the
      etworks\ map with
      unning: boolean, \lastIndexedLedger, \latestLedger, \lagLedgers, and
      eason\ (when stopped/unstarted due to missing configuration).
  3. Validation & Unconfigured-RPC Path Tests:

    • Added unit test in \src/tests/multiNetworkIndexer.test.ts\ covering the unconfigured-RPC path when \startAllIndexers\ encounters a network missing required RPC config (e.g. \SOROBAN_RPC_URL_MAINNET).
    • Added unit tests in \src/tests/staleReads.test.ts\ verifying that reads for a stopped indexer return explicit staleness markers and that /status\ surfaces per-network running status, lag, and unstarted reasons.
  4. Documentation:

    • Updated \README.md\ to document the per-network RPC variables (\SOROBAN_RPC_URL_TESTNET, \SOROBAN_RPC_URL_MAINNET), their resolution order, and behavior when an enabled network indexer is unconfigured.

@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@Stanley471 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

This branch has not been deployed

No deployments
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.

The mainnet indexer never starts, and reads serve stale data without saying so

1 participant