feat: add rate limiting and retry logic to RPC calls in contract.ts#126
Merged
Merged
Conversation
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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
fetch(config.rpcUrl)+ invalidfetchWithRetry(NETWORK.rpcUrl)lines with a single correctfetchWithRetry(config.rpcUrl)for sendTransaction — gains 30 s per-request timeout and automatic retries on 429 / 503 / network errors.await new Promiseand stalefetch(config.rpcUrl)lines; the loop now usesfetchWithRetryfor every getTransaction poll, and the existing 60 s POLL_TIMEOUT_MS deadline prevents infinite waits.Retry policy (already defined, now actually used):
closes #26