Skip to content

Conversation

@fracek
Copy link
Contributor

@fracek fracek commented Jan 25, 2026

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 25, 2026

Warning

Rate limit exceeded

@fracek has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Adds a generic retry utility and integrates it into the EVM RPC stream configuration to wrap several RPC calls (log and block header fetches) with retry logic; also adds a prerelease changelog entry documenting the retry behavior.

Changes

Cohort / File(s) Summary
Changelog Entry
change/@apibara-evm-rpc-61ddce60-5630-4dc6-8e09-e15f67623852.json
Adds a prerelease changelog entry stating a retry mechanism for failed RPC requests; marks release as prerelease and patch-level dependent.
Retry Utility
packages/evm-rpc/src/retry.ts
New exported retry<T>({ fn, maxAttempts = 3, delay = 100 }) utility that retries a promise-returning function with configurable attempts and delay, logging warnings on transient failures.
RPC Call Integration
packages/evm-rpc/src/stream-config.ts
Replaces direct RPC calls with retry-wrapped variants for fetchLogsForRange, fetchLogsByBlockHash, and block-header (eth_getBlockByNumber) fetching; preserves existing error handling hooks.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Client
  participant Retry as RetryUtil
  participant RPC as EVM_RPC_Client
  participant Oracle as BlockRangeOracle

  Client->>Retry: call fetchLogsForRangeWithRetry(fn)
  Retry->>RPC: attempt RPC request (fetch logs / block)
  RPC-->>Retry: success OR error
  alt success
    Retry-->>Client: return result
  else error & attempts < max
    Retry-->>Retry: wait delay
    Retry->>RPC: retry attempt
  else error & attempts >= max
    Retry-->>Oracle: notify via handleError(...)
    Oracle-->>Client: handle error path
    Retry-->>Client: throw error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jaipaljadeja

Poem

🐰 I hop and try once, twice, then thrice,

A patient loop, not cold as ice.
With gentle waits and hopeful cheer,
Failed requests tremble—then reappear.
Hooray, we fetch the logs, my dear!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether the description relates to the changeset. Provide a pull request description that explains the purpose, implementation details, and impact of adding retry logic to the EVM RPC requests.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'Add retry to EVM RPC' clearly and accurately summarizes the main change: adding retry logic to the EVM RPC package.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@packages/evm-rpc/src/retry.ts`:
- Around line 1-20: The retry function may loop indefinitely if maxAttempts or
delay are non-finite/NaN; update retry to validate and clamp input parameters by
ensuring maxAttempts is a finite integer >=1 (fallback to 3) and delay is a
finite non-negative number (fallback to 100), coerce/round maxAttempts (e.g.
Math.floor) and guard attempts against exceeding the clamped maxAttempts before
retrying; locate the retry function and adjust its parameter handling and the
attempts check to use these validated values (references: retry, maxAttempts,
delay, attempts, fn).

In `@packages/evm-rpc/src/stream-config.ts`:
- Around line 275-289: The retry block currently calls
this.blockRangeOracle.handleError(error) inside the retried fn, causing
currentSize to be halved on every attempt; change this by removing handleError
from inside the async fn passed to retry and instead wrap the entire await
retry(...) in a try/catch where you call
this.blockRangeOracle.handleError(error) once before rethrowing; locate the
retry invocation that calls fetchLogsForRange (the function using this.client,
fromBlock, toBlock, filter, mergeGetLogs) and move the handleError call to the
outer catch so state mutation happens only once per error event.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/evm-rpc/src/stream-config.ts`:
- Around line 275-290: The code contains an extra closing token "});" after the
try/catch that breaks parsing; remove the stray "});" so the try { return await
retry({...}) } catch (error) { this.blockRangeOracle.handleError(error); throw
error; } block closes correctly, ensuring the call to retry and the error
handling around fetchLogsForRange remain intact (look for the retry invocation
and this.blockRangeOracle.handleError references to locate the exact spot).

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@fracek fracek merged commit 4bb9c3e into apibara:main Jan 25, 2026
2 checks passed
@fracek fracek deleted the add-retry-to-rpc branch January 25, 2026 12:44
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.

1 participant