Handle response-too-large errors with immediate partition shrinking - #1371
Conversation
Log-dense contracts (e.g. USDC) trip provider response caps that depend on log density, not on a fixed block window — HyperRPC's 50k-log limit (`-32005 "More than 50000 logs returned"`), and similar response-size / result-count limits from Optimism, Arbitrum, ZkEVM, LlamaRPC, 1RPC, Ankr. These carry no numeric block-range suggestion, so they fell through to the transient branch: a fixed 5s backoff wait, while acceleration_additive grew the range straight back over the cap — re-paying 5s on every oscillation. Classify these as deterministic "too large" and react by class: - shrink the range and retry immediately (no backoff wait), and - ratchet the shared max range down so acceleration never re-crosses the cap. The range settles at the largest size that fits and stays there. Factor provider-message extraction into getErrorMessage, shared by the existing block-range parser and the new classifier. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JjhuSDyhUYJV9R64LGo5o3
isResponseTooLargeError now implements the provider cases the comment listed as unhandled; each provider is named inline beside its pattern. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JjhuSDyhUYJV9R64LGo5o3
Fold the provider-suggested and response-too-large deterministic paths into one resize decision (interval + target key) with a single immediate WithSuggestedToBlock throw, leaving one transient WithBackoff path. Lower the default RPC backoff from 5s to 2s so the transient/unclassified retry recovers faster. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JjhuSDyhUYJV9R64LGo5o3
The shrunk interval is branch-independent arithmetic; compute it once as a value instead of allocating a closure inside the catch expression. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JjhuSDyhUYJV9R64LGo5o3
Replace the partitionId-keyed interval dict with two source-level refs: currentBlockInterval (AIMD working range) and sourceMaxBlockInterval (a ceiling that only tightens, set by structural "limited to N blocks" limits). partition ids churn on merge/split, so per-partition interval state silently reset on every reshape and leaked abandoned ids. Source-level keeps the two behaviors we want: a structural limit caps the whole source and never grows back; a density "too many logs" error shrinks and immediately retries, then re-adapts upward on the next successful query. The read min(current, cap) lets a density shrink dip below a structural cap without the cap overriding it. Add a test asserting the interval re-grows after a density shrink. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JjhuSDyhUYJV9R64LGo5o3
Store the AIMD working interval in a dict keyed by partitionId, with a source-wide ceiling under the `max` key that only tightens (structural "limited to N blocks" limits). A "too many logs" density error shrinks only its own partition and re-adapts on the next successful query; the read is min(partition, sourceMax) so a density shrink can dip below the structural cap without the cap overriding it. Partition ids can go stale on merge/split, resetting a partition's learned interval — accepted for now; it re-adapts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JjhuSDyhUYJV9R64LGo5o3
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 31 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Comment |
…-getlogs-retry-oept14 # Conflicts: # packages/envio/src/sources/RpcSource.res
Summary
Add detection and handling for deterministic "response too large" errors from RPC providers that don't include a suggested block range. These errors depend on log density rather than a fixed block window, so they require immediate partition shrinking without backoff, followed by adaptive re-growth on successful queries.
Changes
New
isResponseTooLargeErrorclassifier: Detects density-cap errors from major providers (HyperRPC's 50k-log cap, ZkEVM, LlamaRPC, Optimism, Arbitrum, Ankr, 1RPC) using regex patterns on error messages.Extracted
getErrorMessagehelper: Centralizes error message extraction from bothRpc.JsonRpcErrorand rawJsExnshapes, eliminating duplication in error classifiers.Immediate shrinking on density errors: When
isResponseTooLargeErrormatches and no suggested range is available, shrink the partition interval immediately (no backoff) and retry. This ratchets the max range down until it fits.Adaptive re-growth: The existing AIMD (additive increase/multiplicative decrease) acceleration logic re-grows the partition interval on the next successful query, allowing the system to adapt upward when density decreases.
Source-wide ceiling tracking: Added
maxSuggestedBlockIntervalKeyto track structural provider limits (e.g., "limited to N blocks") that only ever tighten, preventing growth beyond the tightest cap encountered.Comprehensive test coverage: Added tests verifying immediate shrinking on repeated density errors and re-growth after successful queries following a density shrink.
Implementation Details
maxkey ceiling is applied when computing the effective suggested interval, ensuring no partition grows beyond the tightest structural limit.https://claude.ai/code/session_01JjhuSDyhUYJV9R64LGo5o3