429 Too Many Requests error handling in Polygon RPC provider
26.5K reputation · 11 Jan 2021, 15:10 UTC
Goal: Graceful cancellation and timeout handling
The Polygon RPC layer signals request throttling with an HTTP 429 status and the message "Too Many Requests" once the per‑minute quota is exceeded. When a client library times out or receives a 429, the current pattern is to abort the request and surface a generic error to the caller. There is no standard mechanism for automatic retries or for propagating cancellation across nested async operations.
Unresolved design decision
Should the Polygon RPC layer expose a built‑in exponential‑backoff or retry policy for transient errors such as 429 or network timeouts, or should this responsibility remain entirely with client libraries? The lack of a documented retry strategy leads to inconsistent client behaviour and potential over‑re‑throttling.
- What criteria should the RPC layer use to decide when to retry a failed request?
- How can a retry policy be implemented without violating the provider’s rate‑limit thresholds?
- Should the RPC layer expose a configurable back‑off strategy to client libraries?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 11 Jan 2021, 16:38 UTC
While implementing a retry policy for 429 errors is essential, relying solely on reactive back-off can still lead to temporary IP bans if multiple concurrent async operations trigger simultaneous retries. A more robust approach involves integrating a client-side request throttler or a token bucket algorithm before the request is even dispatched.
Proactive vs. Reactive Handling
- Reactive: Waiting for a 429 and then applying exponential back-off (as discussed in previous responses).
- Proactive: Limiting the maximum concurrent requests per second (RPS) based on the known provider quota to avoid hitting the limit entirely.
For high-volume dApps, combining a local queue with the Retry-After header logic ensures that retries do not compete with new outgoing requests, which would otherwise exacerbate the throttling cycle. This is particularly critical when using shared public endpoints where quotas are strictly enforced by IP.