Skip to content

Retry transient RPC errors on equity price reads#71

Open
TaprootFreak wants to merge 1 commit into
developfrom
fix/equity-price-onchain-retry
Open

Retry transient RPC errors on equity price reads#71
TaprootFreak wants to merge 1 commit into
developfrom
fix/equity-price-onchain-retry

Conversation

@TaprootFreak

Copy link
Copy Markdown
Contributor

Problem

TokenService.syncPrices intermittently logs error-level entries when the RPC endpoint has a transient hiccup (observed as recurring bursts on our DEV deployment, ~36/h during an unstable-RPC window):

[TokenService] Failed to update token prices: server response 503 Service Unavailable (... code=SERVER_ERROR, version=6.7.1)
Error: missing revert data (action="call", ...)

Root cause

PriceService.getSpecialTokenPrices reads the equity price directly on the raw provider:

const nativePrice = await equityContract.price();

This is the only on-chain call in the pricing path that bypasses ProviderService's existing transient-error retry policy (withRetry + isTransientRpcError), which getBlock, getBlockNumber, and callBatch already use. A single transient 503 / network blip on this one call fails the whole getTokenPricesInEur cycle.

Fix

  • Expose a public ProviderService.call<T>(thunk) that delegates to the existing private withRetry (same policy: 5 attempts, exponential backoff, transient-only — deterministic errors like execution reverted are not retried).
  • Route the equity price() read through it.

Retry-then-fail-loud: persistent failures still propagate unchanged to the caller, so this does not mask real outages — fully in line with the fail-loud direction of #70 (which this PR does not overlap; #70 touches the GeckoTerminal/FX paths, this touches getSpecialTokenPrices only).

Verification

  • npm run build clean, eslint clean on touched files, prettier clean on price.service.ts (the pre-existing callBatch formatting drift in provider.service.ts is untouched/out of scope).
  • Behavior: transient 5xx/timeout/rate-limit → up to 5 retries with backoff; deterministic revert → immediate propagation as before.

@TaprootFreak TaprootFreak marked this pull request as ready for review June 3, 2026 14:46
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