Skip to content

feat: add rate limiting and retry logic to RPC calls in contract.ts#126

Merged
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
darcszn:feat/rpc-retry-logic
Jun 26, 2026
Merged

feat: add rate limiting and retry logic to RPC calls in contract.ts#126
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
darcszn:feat/rpc-retry-logic

Conversation

@darcszn

@darcszn darcszn commented Jun 25, 2026

Copy link
Copy Markdown

Fixes broken duplicate-line artifacts left from a partial migration, and wires up the already-defined retry/timeout infrastructure to every raw fetch and SDK call that hits the Stellar testnet RPC.

Changes:

  • invoke(): replace duplicate fetch(config.rpcUrl) + invalid fetchWithRetry(NETWORK.rpcUrl) lines with a single correct fetchWithRetry(config.rpcUrl) for sendTransaction — gains 30 s per-request timeout and automatic retries on 429 / 503 / network errors.
  • invoke() poll loop: remove duplicate await new Promise and stale fetch(config.rpcUrl) lines; the loop now uses fetchWithRetry for every getTransaction poll, and the existing 60 s POLL_TIMEOUT_MS deadline prevents infinite waits.
  • createStream(): fix declaration order bug where currentLedger was computed before server was defined; reorder so getServer() runs first, then withRetry(() => server.getLatestLedger()).
  • createStream(): pass the missing config.streamContractId argument to the invoke() call for create_stream — without it the contract address was undefined.

Retry policy (already defined, now actually used):

  • Max 3 retries with 1s/2s/4s exponential backoff
  • Retries on HTTP 429, HTTP 503, and network-level errors (TypeError)
  • 30s AbortController timeout per individual request
  • 60s hard deadline on the transaction-confirmation poll loop

closes #26

Fixes broken duplicate-line artifacts left from a partial migration,
and wires up the already-defined retry/timeout infrastructure to every
raw fetch and SDK call that hits the Stellar testnet RPC.

Changes:
- invoke(): replace duplicate `fetch(config.rpcUrl)` + invalid
  `fetchWithRetry(NETWORK.rpcUrl)` lines with a single correct
  `fetchWithRetry(config.rpcUrl)` for sendTransaction — gains 30 s
  per-request timeout and automatic retries on 429 / 503 / network errors.
- invoke() poll loop: remove duplicate `await new Promise` and stale
  `fetch(config.rpcUrl)` lines; the loop now uses `fetchWithRetry` for
  every getTransaction poll, and the existing 60 s POLL_TIMEOUT_MS
  deadline prevents infinite waits.
- createStream(): fix declaration order bug where currentLedger was
  computed before server was defined; reorder so getServer() runs
  first, then withRetry(() => server.getLatestLedger()).
- createStream(): pass the missing config.streamContractId argument
  to the invoke() call for create_stream — without it the contract
  address was undefined.

Retry policy (already defined, now actually used):
- Max 3 retries with 1s/2s/4s exponential backoff
- Retries on HTTP 429, HTTP 503, and network-level errors (TypeError)
- 30s AbortController timeout per individual request
- 60s hard deadline on the transaction-confirmation poll loop
@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

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

@Austinaminu2 Austinaminu2 merged commit baf3a94 into FlowwStar:main Jun 26, 2026
0 of 3 checks passed
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.

Add rate limiting and retry logic to RPC calls

3 participants