Repository navigation
fix(sdk): retry transient 5xx on read-only RPC calls - #1006
Closed
arkhindi12 wants to merge 1 commit into
Closed
arkhindi12 wants to merge 1 commit into
arkhindi12 wants to merge 1 commit into
Conversation
…l#980) Soroban RPC is POST-only, so retrying by HTTP verb would either never fire or replay sendTransaction. Decide idempotency from the JSON-RPC method instead: getLatestLedger/getAccount/simulateTransaction and friends are safe to replay, sendTransaction never is. Three attempts by default with exponential backoff plus jitter, abort-aware, and 501 is excluded because 'not implemented' will not fix itself.
Contributor
Author
|
Closing this — the issue was resolved by #1015, so this PR is superseded. Thanks for the review queue space. |
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.
Closes #980.
Problem
customFetchhanded every request straight to the user'sfetch. A single502/503 from a public Soroban RPC node — routine during deploys and LB
rotations — surfaced as a hard failure, even though the same read succeeds a
second later.
Why the fix keys off the JSON-RPC method, not the HTTP verb
Soroban RPC is POST-only, so "retry GET" would never fire in practice, and
"retry POST" would replay
sendTransactionand submit a transaction twice.isIdempotentRequest()therefore looks at the body: requests whose JSON-RPCmethod is read-only (
getLatestLedger,getAccount,getLedgerEntries,simulateTransaction,getEvents,getTransaction,getFeeStats, …) areretryable; everything else,
sendTransactionabove all, is sent exactly once.Behaviour
fleet of workers does not retry in lockstep
501is excluded — "not implemented" will not fix itselfsetCustomFetchRetryPolicy()/resetCustomFetchRetryPolicy()for tuningTests
src/tests/custom-fetch-retry.test.ts— 8 cases: 503→200 retried, exhaustionsurfaces the last 5xx, 404 and 501 not retried,
sendTransactionneverretried, dropped connection retried,
maxAttempts: 1disables retrying, anda nonsensical policy throws instead of silently clamping.
Rebased on
mainafter #1004.npx tsc --noEmitand this PR's test suite are green on the current head.