Skip to content

perf: stop regenerating the UI token index on every deploy#1271

Merged
Majorfi merged 1 commit into
mainfrom
perf/ui-index-in-ci
Jul 10, 2026
Merged

perf: stop regenerating the UI token index on every deploy#1271
Majorfi merged 1 commit into
mainfrom
perf/ui-index-in-ci

Conversation

@Majorfi

@Majorfi Majorfi commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Every Vercel deploy of the UI ran prebuildgenerateIndex.mjs, which enriches ~4200 tokens by hitting public RPCs + DefiLlama sequentially (multicall chunks + mcap batches, one chain after another, with an 8s-timeout-plus-retry per chunk). Result: ~16 min per deploy, even for a one-line UI change. The metadata it fetches only changes when tokens change — not when the frontend does.

Fix

Decouple index generation from the frontend build:

  • Commit the generated index (_config/ui/public/data) instead of gitignoring it.
  • prebuildgenerateIndex.mjs --if-missing: the script early-returns when public/data/chains.json exists, so the Vercel build reads the committed index instead of regenerating it. Deploys drop to a plain next build.
  • ui-refresh.yml now regenerates AND commits the index back to main, which triggers a normal (now fast) redeploy. The old deploy-hook POST is dropped.

The refresh workflow

  • Triggers: push on main filtered to tokens/**/logo.svg + chains/**/logo.svg (real logo adds/removes only — deliberately not the ~4-6×/day [bot] - Update lists commits, which touch tokens/*/list.json/_info.json and don't change the generated index), plus weekly (market-cap refresh) + workflow_dispatch.
  • Guard against a broken run: refuses to commit if totalTokens < 1000 or drops >20% vs the committed baseline — an RPC/DefiLlama outage during the job can't ship a degraded index.
  • No loop: GITHUB_TOKEN pushes don't re-trigger workflows, and the committed data path (public/data/**) isn't in the trigger filter.
  • Needs permissions: contents: write (it pushes) + fetch-depth: 0 (recency dates from git history).

Behavior to know

Adding a token → Vercel deploys immediately with the old index (fast, token not listed yet) → the workflow regenerates + commits → a second fast deploy lists it. Two fast deploys instead of one 16-min deploy. The logo itself (CDN/jsDelivr) is served immediately regardless. A Vercel "Ignored Build Step" on tokens/** could collapse this to one deploy later (dashboard config, not code).

Verification

  • Confirmed --if-missing early-returns when chains.json exists (generateIndex.mjs:370).
  • Seed committed: 38 chains, 4253 tokens.
  • Workflow YAML validated.

Not measured on a real Vercel build (no access) — the speedup is proven by the mechanism (early-return + committed index present). The first deploy after merge will confirm the number.

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
token-assets Ready Ready Preview, Comment Jul 10, 2026 5:42pm

Request Review

…build

The prebuild ran generateIndex.mjs on every Vercel deploy, hitting public
RPCs + DefiLlama to enrich ~4200 tokens sequentially (~16 min per deploy,
even for a one-line UI change). The metadata it fetches changes only when
tokens change, not when the frontend does.

Commit the generated index (public/data) and make prebuild --if-missing so
the Vercel build reads it instead of regenerating it — deploys drop to a
plain next build. The refresh workflow now regenerates the index and commits
it back (on a real logo change and weekly for market caps), which triggers a
normal, fast redeploy. A count guard refuses to commit a collapsed index if
an RPC/DefiLlama outage degrades a run.
@Majorfi Majorfi force-pushed the perf/ui-index-in-ci branch from 91e310b to 2079a76 Compare July 10, 2026 17:41
@Majorfi Majorfi merged commit 80c414b into main Jul 10, 2026
7 checks passed
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