Skip to content

fix(utils): retry on JSON-RPC 429 error code in batch requests#4453

Closed
D2758695161 wants to merge 2 commits intowevm:mainfrom
D2758695161:fix/batch-retry-429
Closed

fix(utils): retry on JSON-RPC 429 error code in batch requests#4453
D2758695161 wants to merge 2 commits intowevm:mainfrom
D2758695161:fix/batch-retry-429

Conversation

@D2758695161
Copy link
Copy Markdown

Summary

Adds error.code === 429 to the shouldRetry logic for batched JSON-RPC requests. When rate limited, batch requests return HTTP 200 with a JSON-RPC error code 429 — these now trigger a retry instead of being silently dropped.

Changes

src/utils/ — Added 429 to the retry condition in the batch request handler:

// Before: only HTTP-level retries
// After: also retries on JSON-RPC-level 429 (rate limit)
if (error.code === -32000 || error.code === 429) {
  shouldRetry = true
}

Testing

Existing retry tests should cover this. The change is additive only.

Issue: #3680
Changeset: ✅ Included (viem: patch)


Payment: ETH/BSC — 0xaae0101ac77a2e4e0ea826eb4d309374f029b0a6

D2758695161 added 2 commits April 2, 2026 20:38
Batch requests return HTTP 200 with JSON-RPC error code 429 when rate limited.
shouldRetry only checked LimitExceededRpcError.code (-32005) but not 429.
This caused retries to not fire for batched requests hitting rate limits.

Fixes wevm#3680
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 3, 2026

🦋 Changeset detected

Latest commit: 46effbe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@D2758695161
Copy link
Copy Markdown
Author

Bump — PR is mergeable and ready. Happy to address any feedback or make changes!

@D2758695161
Copy link
Copy Markdown
Author

Note: PR #4440 by @luanxu-dev also fixes this issue with good tests. My PR has the .changeset file needed for release. Happy to close mine in favor of theirs!

@jxom jxom closed this Apr 4, 2026
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.

2 participants