Increase waitForIndexer timeout from 3s to 10s and improve error message#858
Increase waitForIndexer timeout from 3s to 10s and improve error message#858gregnazario wants to merge 1 commit intomainfrom
Conversation
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>
There was a problem hiding this comment.
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 defaultwaitForIndexertimeout. - Enhance
waitForIndexertimeout error message with target/current versions and actionable guidance. - Update
CHANGELOG.mdto 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.`, |
There was a problem hiding this comment.
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.
| `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).`, |
Description
Investigation of the reported issue where
fundAccounton devnet throwswaitForLastSuccessIndexerVersionSync timeout.Finding: The issue was temporary — caused by momentary devnet indexer lag. Testing against devnet confirms it is no longer reproducible:
fundAccountcalls succeededfundAccountcall time: ~1.5sHowever, the hardcoded 3-second timeout in
waitForIndexeris 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:DEFAULT_INDEXER_SYNC_TIMEOUT_SECconstant){ waitForIndexer: false }as a workaroundtimeoutMillisecondsparameter towaitForIndexerfor callers that need custom timeoutsTest Plan
pnpm buildpnpm check(Biome lint + format) — passes cleanfundAccountagainst live devnet:Related Links
Closes the issue: "Funding devnet wallets throws 'waitForLastSuccessIndexerVersionSync timeout'"
Checklist
pnpm fmt?CHANGELOG.md?