Skip to content

fix(api): detect stale/lagging RPC node in health check [BUG-109] - #224

Open
Morenikeoa wants to merge 1 commit into
dcccrypto:mainfrom
Morenikeoa:fix/health-rpc-staleness-check
Open

fix(api): detect stale/lagging RPC node in health check [BUG-109]#224
Morenikeoa wants to merge 1 commit into
dcccrypto:mainfrom
Morenikeoa:fix/health-rpc-staleness-check

Conversation

@Morenikeoa

Copy link
Copy Markdown

Bug

The /health endpoint's RPC check only verifies that getSlot() resolves within the timeout. An RPC node that is up and responsive but stuck (e.g. wedged sync, snapshot replay loop) will keep returning a valid — but non-advancing — slot, and the health check will report rpc: true forever. This defeats the purpose of the check for catching a degraded-but-responsive RPC provider.

Fix

Track the last (slot, checkedAt) reading in module state. On each check, if the new slot hasn't advanced past the last one and enough wall-clock time has elapsed for a live node to have produced new slots, mark checks.rpc = false and log the staleness with the elapsed time. The threshold is 30s — Solana's slot time is ~400-600ms even under congestion, so this is a wide margin, not a tight one. The first reading after a cache reset is always treated as healthy (no prior baseline to compare against).

__resetHealthCache() now also clears the staleness baseline for test isolation.

Test plan

  • Added RPC staleness detection (BUG-109) describe block to tests/routes/health.test.ts with 3 cases (stale node flagged after 30s+ of no slot advancement, genuine slot advancement not flagged, rapid successive checks within the threshold not flagged) using vi.useFakeTimers().
  • Verified the new tests are genuine regressions: reverted src/routes/health.ts via git stash, confirmed the staleness-detection test fails against the unfixed code, restored the fix.
  • Full suite passes (297/298 — the 1 pre-existing failure is unrelated to this change, in adl.test.ts).
  • tsc --noEmit clean.

The /health RPC check only verified that getSlot() resolved within the
timeout, so an RPC node that responds but never advances its slot would
report healthy forever. Track the last reading and flag the check as
failed if the slot hasn't advanced after 30s (a wide margin given
Solana's ~400-600ms slot time).
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

@Princessdada is attempting to deploy a commit to the Khubair Nasir's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Morenikeoa, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 19 minutes and 7 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

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 credits.

🚦 How do rate 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 see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ddd733ef-4db3-404c-885b-449bb091921c

📥 Commits

Reviewing files that changed from the base of the PR and between b2751f4 and cee595d.

📒 Files selected for processing (2)
  • src/routes/health.ts
  • tests/routes/health.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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