Skip to content

fix: throttle upstream RPC-provider error reporting to stop log amplification - #1453

Closed
tony8713 wants to merge 1 commit into
masterfrom
fix/rpc-error-log-amplification
Closed

fix: throttle upstream RPC-provider error reporting to stop log amplification#1453
tony8713 wants to merge 1 commit into
masterfrom
fix/rpc-error-log-amplification

Conversation

@tony8713

@tony8713 tony8713 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Problem

When the shared RPC proxy behind rpc.snapshot.org returns 403s or 5xx, every affected strategy call throws, and score-api writes a log line per failed request. That line stringifies the full strategies payload along with the error, so a brief upstream fault turns into sustained log volume that blocks the event loop. score-api then stops answering inside the HTTP header timeout and the uptime check opens an incident, which clears as soon as the burst does.

The upstream fault is short. The amplification is ours, and it is what turns the fault into an outage.

Fix

New src/helpers/providerErrors.ts:

  • isProviderError separates upstream RPC failures from genuine input and validation errors.
  • summarizeError builds a bounded single-line summary, so the strategies payload and the full error object are no longer stringified per request.
  • shouldReport allows one report per key per time window, keyed on method or network plus the error code.

src/rpc.ts applies these on both error paths. An upstream-provider error gets the bounded, throttled line. Everything else behaves exactly as before, and the 500 sent to the client is unchanged in all cases.

The Sentry capture is throttled on the same key, which makes the captures that survive a storm a predictable one per key per window rather than whichever ones happened to arrive first.

Non-goals

The 403 itself is upstream and is being handled separately. Per-strategy provider timeouts are left alone, since tightening them would change scoring for slow but valid strategies and deserves its own change.

🤖 Generated with Claude Code

…fication

When rpc.snapshot.org (the shared RPC proxy) returns HTTP 403/5xx, ethers
throws a SERVER_ERROR/CALL_EXCEPTION for every failing strategy call.
score-api was calling capture() (Sentry) and console.log once per failed
request. During a provider outage that is thousands of failures per minute,
each serializing the full ethers error object, which stalls the event loop
and makes score-api miss the HTTP header timeout (the score.snapshot.org
flapping).

Add helpers/providerErrors with isProviderError(), summarizeError(), and a
time-windowed shouldReport() throttle, and apply it in both error paths in
rpc.ts so a provider outage produces a sampled trickle of reports instead of
a self-inflicted flood. Behaviour for non-provider errors is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wa0x6e

wa0x6e commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Closing: this approach isn't the right fit. The underlying problem is tracked in #1470 for a different fix.

@wa0x6e wa0x6e closed this Aug 16, 2026
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