Skip to content

fix: stop flooding LOS /tokens/{token_id} and keep token pages up on 429 - #1396

Open
kuan121 wants to merge 4 commits into
mainfrom
fix/los-token-throttling
Open

kuan121 wants to merge 4 commits into
mainfrom
fix/los-token-throttling

Conversation

@kuan121

@kuan121 kuan121 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Stops the Explorer from flooding LOS /tokens/{token_id}, and keeps the token page usable when LOS throttles it.

  • Vault price poller (DGE-8410): read RWA token prices from the /trusted-tokens response the poller already fetches. That's 1 LOS request per pod every 5 minutes instead of ~850.
  • Token page (DGE-8266): retry /tokens/{id} on 429. If it still fails, show the issuer and a "token details unavailable" notice instead of the error page.
  • Holders show -- for USD value when there's no price, instead of $NaN.

Context of Change

Each pod requested /tokens/{token_id} once per RWA token (850 today), all at once, every 5 minutes. The bursts are far over the route's rate limit, even after LOS #137 raised it to 100/s with a burst of 200. So most get 429, and so do users' token pages. /trusted-tokens already returns the same price that /tokens/{token_id} reads for a trusted token. I didn't use POST /tokens/batch-get: it reads the general tokens table, not trusted-tokens, so prices could differ.

On the token page, retries were off (retry: false in the shared QueryClient), and any /tokens/{id} error replaced the whole page. Now:

  • Retried up to 3 times (1s, 2s, 4s) on a 429 or a network error. A throttled response without CORS headers shows up as a network error.
  • 404/400: still the error page, with no retry.
  • Any other failure after retries, including a 500: the page renders with the notice. The issuer stays visible so tokens with the same code can be told apart.
  • Other sections load on their own: all transactions and AMM TVL from rippled, holders from XRPL Meta. DEX trades and transfers come from LOS, so they fail too if LOS is fully down.
  • During retries the full-page loader stays up for up to ~7s. Showing the tables early would make the page jump, and would briefly show tables for a 404 token.

Not fixed here: a 404 shows "Something bad happened" instead of its own message, because the error lookup gets the error object rather than the status. This predates the PR, and the 404 text ("Account not found") is wrong for tokens, so it needs new copy.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Translation Updates

Codebase Modernization

  • Updated files to React Hooks
  • Updated files to TypeScript

Not needed: the touched components are already TypeScript function components, and server/ is plain JavaScript.

Before / After

Case Before After
Vault prices ~850 parallel /tokens/{token_id} per pod per 5 min, mostly 429 No per-token requests; /api/v1/vaults/asset-prices response unchanged
Token page, one 429 Error page Retried, then loads normally
Token page, LOS keeps failing Error page Issuer + "Token details are unavailable right now. Please try again later."
Token page, 404/400 Error page Unchanged

Only 36 of the 850 RWA tokens have a non-zero price in LOS. A vault asset that still has no price is missing it in LOS.

Test Plan

  • New tests, each failing on the old code: vault prices come from /trusted-tokens with no /tokens/{id} request; a 429 is retried and the token renders; repeated failures render the page with the issuer and notice; a price-less holder shows --.
  • Also covered: the retry rules (429 and network errors retried; 400/404/500 not; stops after 3) and a 404 showing the error page with no retry.
  • Checked against live LOS that /trusted-tokens returns price for RWA tokens.
  • CI green. Not run in a browser.

kuan121 and others added 2 commits November 19, 2026 15:39
…call per token

The vault price poller requested /tokens/{token_id} once per RWA token, all
in parallel, every 5 minutes on every pod (850 requests per pod today). The
bursts exceed LOS's per-route rate limit, so most price requests got 429 and
so did real users of the token page.

/trusted-tokens already returns each token's price (the same item
/tokens/{token_id} reads for a trusted token), so read it from there. That's
one LOS request per cycle.

DGE-8410

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…OS fails

The token page sent /tokens/{id} once with retries off, and any failure
replaced the whole page with an error, even though the token exists and the
other sections load from other sources.

- Retry the token request up to 3 times (1s, 2s, 4s) on 429 or a network
  error, which is how a throttled response without CORS headers looks.
- A 404 or 400 still shows the error page. Any other failure renders the page
  with a "token details unavailable" notice in the header, so holders, DEX
  trades and transfers still load.
- Show "--" for a holder's USD value when the token has no price, instead of
  "$NaN".

DGE-8266

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ripple-code-reviewer ripple-code-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found.

…ests

- When LOS fails, the "token details unavailable" header now still shows
  the issuer, so tokens that share a currency code can be told apart.
- The vault price test waits for the price cache instead of a fixed number
  of promise ticks.
- The IOU page tests clear the shared query cache between tests, and the
  404 test checks only that the error page shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ripple-code-reviewer ripple-code-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found.

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