fix(api): detect stale/lagging RPC node in health check [BUG-109] - #224
fix(api): detect stale/lagging RPC node in health check [BUG-109]#224Morenikeoa wants to merge 1 commit into
Conversation
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).
|
@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. |
|
Warning Review limit reached
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Bug
The
/healthendpoint's RPC check only verifies thatgetSlot()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 reportrpc: trueforever. 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, markchecks.rpc = falseand 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
RPC staleness detection (BUG-109)describe block totests/routes/health.test.tswith 3 cases (stale node flagged after 30s+ of no slot advancement, genuine slot advancement not flagged, rapid successive checks within the threshold not flagged) usingvi.useFakeTimers().src/routes/health.tsviagit stash, confirmed the staleness-detection test fails against the unfixed code, restored the fix.adl.test.ts).tsc --noEmitclean.