Skip to content

Increase waitForIndexer timeout from 3s to 10s and improve error message#858

Open
gregnazario wants to merge 1 commit intomainfrom
cursor/indexer-sync-timeout-temporary-44ad
Open

Increase waitForIndexer timeout from 3s to 10s and improve error message#858
gregnazario wants to merge 1 commit intomainfrom
cursor/indexer-sync-timeout-temporary-44ad

Conversation

@gregnazario
Copy link
Collaborator

Description

Investigation of the reported issue where fundAccount on devnet throws waitForLastSuccessIndexerVersionSync timeout.

Finding: The issue was temporary — caused by momentary devnet indexer lag. Testing against devnet confirms it is no longer reproducible:

  • 5/5 sequential fundAccount calls succeeded
  • Indexer synced in ~844ms (well within the old 3s timeout)
  • Average total fundAccount call time: ~1.5s

However, the hardcoded 3-second timeout in waitForIndexer is fragile. During any temporary indexer lag on public networks, users would hit this error with no useful guidance. This PR makes the SDK more resilient:

  1. Increased default timeout from 3s to 10s (DEFAULT_INDEXER_SYNC_TIMEOUT_SEC constant)
  2. Improved error message to include:
    • Current indexer version and target version (helps diagnose the gap)
    • Suggestion to use { waitForIndexer: false } as a workaround
  3. Added optional timeoutMilliseconds parameter to waitForIndexer for callers that need custom timeouts

Test Plan

  1. Built the SDK successfully with pnpm build
  2. Ran pnpm check (Biome lint + format) — passes clean
  3. Tested fundAccount against live devnet:
    • 3/3 calls succeeded with the updated code (avg 1.6s)
    • Confirmed indexer sync completes well within the new 10s default
  4. Verified the error message improvement by code review — timeout now includes version details and actionable guidance

Related Links

Closes the issue: "Funding devnet wallets throws 'waitForLastSuccessIndexerVersionSync timeout'"

Checklist

  • Have you ran pnpm fmt?
  • Have you updated the CHANGELOG.md?
Open in Web Open in Cursor 

The waitForLastSuccessIndexerVersionSync timeout error reported in the issue
was caused by a temporary devnet indexer lag combined with an aggressively
short 3-second hardcoded timeout. Testing against devnet confirms the issue
is no longer reproducible (indexer syncs in ~844ms, 5/5 attempts succeed).

Changes:
- Add DEFAULT_INDEXER_SYNC_TIMEOUT_SEC constant (10 seconds) to utils/const.ts
- Increase waitForIndexer default timeout from 3s to 10s for resilience
  against temporary indexer lag on public networks
- Accept optional timeoutMilliseconds parameter in waitForIndexer for callers
  that need custom timeouts
- Improve error message to include current indexer version, target version,
  and suggest { waitForIndexer: false } as a workaround

Co-authored-by: Greg Nazario <greg@gnazar.io>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves resilience around indexer synchronization waits (notably for fundAccount) by increasing the default wait timeout, making the timeout configurable internally, and enhancing timeout diagnostics.

Changes:

  • Add DEFAULT_INDEXER_SYNC_TIMEOUT_SEC (10s) and use it as the default waitForIndexer timeout.
  • Enhance waitForIndexer timeout error message with target/current versions and actionable guidance.
  • Update CHANGELOG.md to document the behavior change and improved error messaging.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/utils/const.ts Introduces a new default indexer sync timeout constant (10s) with documentation.
src/internal/transaction.ts Uses the new default timeout, adds an optional timeoutMilliseconds override, and improves timeout error text.
CHANGELOG.md Documents the increased timeout and improved error message.
Comments suppressed due to low confidence (1)

src/internal/transaction.ts:341

  • With the default timeout increased to 10s, this loop can now poll the indexer up to ~50 times (200ms sleep) per call, which may increase load and the chance of rate limiting during lag events. Consider increasing the polling interval, using a simple backoff strategy, and/or making the poll interval configurable to reduce request volume during extended waits.

    await sleep(200);
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

`Timeout waiting for indexer to sync to version ${minimumLedgerVersion}. ` +
`Indexer is at version ${indexerVersion}. ` +
`This may indicate the indexer is lagging behind the fullnode. ` +
`You can pass { waitForIndexer: false } in the options to skip waiting.`,
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout error message suggests passing { waitForIndexer: false } in the options, but waitForIndexer() is also used by waitForIndexerOnVersion() and other call sites that don’t have a waitForIndexer option (they only control waiting by providing/omitting minimumLedgerVersion). Consider making the guidance conditional/generic (e.g., mention omitting minimumLedgerVersion or disabling indexer waiting where supported) so it isn’t misleading for those callers.

Suggested change
`You can pass { waitForIndexer: false } in the options to skip waiting.`,
`If supported by the API you are using, you can disable waiting for the indexer (for example, by omitting ` +
`a minimumLedgerVersion or turning off indexer waiting in the options).`,

Copilot uses AI. Check for mistakes.
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.

3 participants