Skip to content

Handle response-too-large errors with immediate partition shrinking - #1371

Merged
DZakh merged 7 commits into
mainfrom
claude/hyperindex-eth-getlogs-retry-oept14
Jul 1, 2026
Merged

Handle response-too-large errors with immediate partition shrinking#1371
DZakh merged 7 commits into
mainfrom
claude/hyperindex-eth-getlogs-retry-oept14

Conversation

@DZakh

@DZakh DZakh commented Jul 1, 2026

Copy link
Copy Markdown
Member

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 isResponseTooLargeError classifier: 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 getErrorMessage helper: Centralizes error message extraction from both Rpc.JsonRpcError and raw JsExn shapes, eliminating duplication in error classifiers.

  • Immediate shrinking on density errors: When isResponseTooLargeError matches 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 maxSuggestedBlockIntervalKey to 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

  • Density errors are distinguished from transient errors: transient errors trigger backoff + shrinking, while density errors trigger immediate shrinking without backoff.
  • The partition-level interval can go stale when partitions merge/split, but re-adapts naturally on the next query.
  • The source-wide max key ceiling is applied when computing the effective suggested interval, ensuring no partition grows beyond the tightest structural limit.

https://claude.ai/code/session_01JjhuSDyhUYJV9R64LGo5o3

claude added 6 commits July 1, 2026 11:25
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
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ba31195b-cc4e-4192-a0fc-8f39652e9a25

📥 Commits

Reviewing files that changed from the base of the PR and between 8b57b1c and 85b7acb.

📒 Files selected for processing (3)
  • packages/envio/src/sources/EvmChain.res
  • packages/envio/src/sources/RpcSource.res
  • scenarios/test_codegen/test/RpcSource_test.res

Comment @coderabbitai help to get the list of available commands.

…-getlogs-retry-oept14

# Conflicts:
#	packages/envio/src/sources/RpcSource.res
@DZakh
DZakh merged commit 3569f75 into main Jul 1, 2026
8 checks passed
@DZakh
DZakh deleted the claude/hyperindex-eth-getlogs-retry-oept14 branch July 1, 2026 14:16
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