Fix/rpc retry - #353
Merged
Merged
Conversation
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 #325
Description
This PR resolves the issue where transient RPC errors (such as timeouts, rate limits, and temporary node unavailability) were propagating immediately and causing avoidable failures in access checks. It introduces a resilient, configurable exponential backoff retry mechanism in
ContractClientto ensure transient failures are seamlessly retried without caller intervention.Linked Issue
Closes #
Type of Change
Changes Made
packages/integration-client/src/contracts/contractHelpers.ts: IntroducedwithRetry(fn, options)utility which executes functions with exponential backoff and jitter. AddedisRetryableError(error)to determine which errors are safe to retry (e.g., RPC rate limits like-32005, HTTP429,500-504, connection resets, and timeouts).packages/integration-client/src/config/sdkConfig.ts: AddedsdkConfig.rpcRetrysetting to make the max attempts, base delay, and max delay configurable globally.packages/integration-client/src/contracts/contractClient.ts: Wrapped the RPCcall()execution with the newwithRetryutility utilizing thesdkConfig.packages/integration-client/test/contracts.test.ts: Implemented unit tests simulating both transient JSON-RPC failures followed by success (verifying the retry works), as well as permanent JSON-RPC failures (verifying that they fail immediately without draining retry attempts).packages/integration-client/src/index.ts: Exported the new helper and config modules for downstream usage.Test Evidence
Automated unit tests have been added and successfully run against the new retry logic. The tests verify:
ContractClient - retry on transient JSON-RPC error: Successfully intercepts a JSON-RPC-32005(rate limit) error returned with an HTTP 200 OK, applies the backoff delay, and successfully retrieves the result on the second attempt.ContractClient - no retry on permanent JSON-RPC error: Successfully intercepts a JSON-RPC3(execution reverted) error and immediately fails without attempting to retry.Checklist
pnpm typecheckpasses with no errorspnpm lintpasses (or issues are pre-existing and documented)pnpm testpasses (all existing tests still pass)pnpm dev:docs.env.exampleScreenshots / Recordings
N/A (SDK / Backend utility change).
Additional Notes
This specifically targets JSON-RPC payload errors (like rate limits returned with a 200 OK status) that standard HTTP transport-layer retries miss.