Difficulty: Intermediate
Type: Refactor
Recommended labels (if available in this repo): enhancement, reliability, sdk
Background
src/contracts/contractClient.ts makes direct RPC calls via the configured provider. The provider layer (src/contracts/providers/jsonRpcProvider.ts, webSocketProvider.ts) handles low-level transport, but there is no consistent retry policy applied at the client call level for transient RPC failures.
Problem
Transient RPC errors (timeouts, rate limits, temporary node unavailability) currently propagate immediately to the caller with no retry, causing avoidable failures in access checks under normal network flakiness.
Expected Outcome
contractClient.ts calls are wrapped with a configurable exponential-backoff retry policy for a defined set of retryable error types (timeouts, 429s, connection resets), while non-retryable errors (e.g. revert reasons) fail immediately.
Suggested Implementation
Add a small retry utility (withRetry(fn, options)) with max attempts, base delay, and jitter. Apply it around the RPC call sites in contractClient.ts. Use src/errors/errorCodes.ts to classify which errors are retryable vs. terminal.
Acceptance Criteria
- Retryable errors (timeout, connection reset, rate limit) are retried with exponential backoff up to a configurable max attempts
- Non-retryable errors (e.g. contract revert) are not retried
- Retry behavior is configurable via
sdkConfig.ts
- Unit tests simulate transient failures followed by success, and permanent failures
pnpm test:run passes
Likely Affected Files/Directories
src/contracts/contractClient.ts
src/contracts/contractHelpers.ts
src/errors/errorCodes.ts
src/config/sdkConfig.ts
Difficulty: Intermediate
Type: Refactor
Recommended labels (if available in this repo):
enhancement,reliability,sdkBackground
src/contracts/contractClient.tsmakes direct RPC calls via the configured provider. The provider layer (src/contracts/providers/jsonRpcProvider.ts,webSocketProvider.ts) handles low-level transport, but there is no consistent retry policy applied at the client call level for transient RPC failures.Problem
Transient RPC errors (timeouts, rate limits, temporary node unavailability) currently propagate immediately to the caller with no retry, causing avoidable failures in access checks under normal network flakiness.
Expected Outcome
contractClient.tscalls are wrapped with a configurable exponential-backoff retry policy for a defined set of retryable error types (timeouts, 429s, connection resets), while non-retryable errors (e.g. revert reasons) fail immediately.Suggested Implementation
Add a small retry utility (
withRetry(fn, options)) with max attempts, base delay, and jitter. Apply it around the RPC call sites incontractClient.ts. Usesrc/errors/errorCodes.tsto classify which errors are retryable vs. terminal.Acceptance Criteria
sdkConfig.tspnpm test:runpassesLikely Affected Files/Directories
src/contracts/contractClient.tssrc/contracts/contractHelpers.tssrc/errors/errorCodes.tssrc/config/sdkConfig.ts