Skip to content

perf(dashboard): Serve dashboard browser files as static assets - #2725

Merged
thomasjiangcy merged 3 commits into
mainfrom
perf/dashboard-static-assets
Nov 5, 2026
Merged

thomasjiangcy merged 3 commits into
mainfrom
perf/dashboard-static-assets

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

The dashboard loaded client.js from the function with cache-control: no-store, so every page load downloaded it again. In EU and APAC traces, that one file took 0.65–1.5s per page load.

The client build now writes only files with a content hash in the name (client-[hash].js, chunks/[name]-[hash].js) into dist/public. juniorNitro() adds that folder as a Nitro public asset dir at /_junior/dashboard/assets, with a one-year maxAge and fallthrough: false. On Vercel the files go to .vercel/output/static, so the CDN serves them without calling the function. The dashboard Hono app serves the same URLs from embedded files, for dev and for hosts that don't use Nitro. Unknown names get a 404 with no-store. The HTML names the hashed entry directly, so the ?v= query is gone.

Behavior change: these files no longer need auth. They are the same bytes that ship in the npm package.

Build evidence (Vercel preset, local nitro build of a fixture app)

  • .vercel/output/static/_junior/dashboard/assets/ has 89 files (1 entry, 88 chunks). Every name is hashed. Nothing else from the dashboard lands in static output.
  • config.json routes: a header route for /_junior/dashboard/assets(.*) (public,max-age=31536000,immutable, continue: true), then handle: filesystem, then /(.*) → /__server.
  • The function bundle has no runtime route rules (findRouteRules returns []), so for a missing file the function sends only the dashboard's 404 no-store.

Verified on a real Vercel deployment
Tested on a junior-prod source preview of 8a005cc29 (dpl_4c3GmmsRUEG3gVsgkwEhSY24q8pa). The later commit only changes how the script src is encoded.

  • Page /: 200, cache-control: no-store, and the script tag points at /_junior/dashboard/assets/client-H223ID3P.js.
  • Real entry and chunk: 200, public,max-age=31536000,immutable. The second request was a CDN HIT. The entry is served brotli-compressed: 829 KB on the wire, 2.84 MB raw.
  • Made-up hashes (client-AAAAAAAA.js, chunks/nope-AAAAAAAA.js): 404, cache-control: no-store, on both of two requests. The function's header overrides the prefix's header route, so a missing hash never gets the one-year header. That keeps Instant Rollback safe, and the header doesn't need to be set per file.
  • The old /_junior/dashboard/client.js: 404 (Vercel default headers).

Cache-busting checks

  • Changing one chunk renames the entry too: a content change to one chunk alone renamed csv-I2Y5BPVG.js → csv-JE52RRHZ.js and the entry client-H223ID3P.js → client-W4ZTL7FG.js.
  • Only hashed files under the prefix: the server build fails if dist/public has an unhashed name or more than one entry. The output test checks the static dir too.
  • Dev freshness: without embedded assets, the shell reads dist/public on each render. In one running process, a client rebuild changed the name from client-H223ID3P.js to client-HJLLTKQR.js. The new file returned 200 and the deleted one returned 404.

Follow-ups

  • Turn on Vercel Skew Protection with Nitro vercel.skewProtection, so open tabs keep loading chunks from their own deployment.
  • Serve Tailwind CSS as a hashed asset as well. It is still inlined.

via @thomasjiangcy.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 5, 2026 9:36am UTC

Request Review

@blacksmith-sh

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

3 screenshot changes — 3 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Run Details Light · Desktop
Automation Run Details Light · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 5, 2026 09:22
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 5, 2026
@thomasjiangcy
thomasjiangcy merged commit c083a1d into main Nov 5, 2026
44 checks passed
@thomasjiangcy
thomasjiangcy deleted the perf/dashboard-static-assets branch November 5, 2026 09:42
BYK added a commit that referenced this pull request Nov 5, 2026
…ets (#2757)

The page shell had the full Tailwind stylesheet (177 KB raw / 28 KB
gzip) inline in every `no-store` HTML response. It also loaded Inter and
Outfit through a render-blocking Google Fonts `@import`, which needs two
more origins. The header and transcript avatar was a 76 KB PNG that was
not hashed.

- The client build now bundles `src/styles.css` (self-hosted fontsource
variable fonts + `dist/tailwind.css`) into `styles-[hash].css`. The
fonts are `*-[hash].woff2` files under `/_junior/dashboard/assets`, the
same immutable prefix as the JS from #2725. Fonts keep `font-display:
swap`.
- The shell links the stylesheet and preloads the two Latin font files.
The other subsets load only when a page uses them. The forbidden page
uses the same stylesheet link.
- The avatar is an 88×88 (2× of `size-11`) hashed WebP: 3.2 KB. No PNG
fallback, because every supported browser decodes WebP.
`/_junior/dashboard/avatar.png` stays for older cached clients and the
install icons.
- Binary public assets are embedded as base64 and served with the
content type from their extension.
- Core no longer copies `tailwind.css` into server output. Nothing reads
it now.

### Numbers (`/conversations`, mock conversations, production build)

| | before | after |
|---|---|---|
| HTML raw / gzip / br | 189,104 / 31,888 / 24,789 B | **11,141 / 2,902
/ 2,292 B** |
| Third-party origins | fonts.googleapis.com, fonts.gstatic.com |
**none** |
| Render-blocking chain | HTML → Google CSS → gstatic woff2 | HTML →
hashed CSS (fonts preloaded in parallel) |
| `modulepreload` links | 58 | 58 (unchanged, see below) |
| Avatar | 76,539 B PNG, revalidated | 3,206 B WebP, immutable |
| Cold first load, same-origin br (HTML + head assets) | 498,513 B |
580,255 B |

On a cold load, the first-load figure goes up because the CSS (23 KB br)
and the Latin fonts (48 + 32 KB) now come from our origin instead of
Google. The browser fetched about the same font bytes from gstatic
before. On every later load, all of that is cached as immutable, so the
HTML is the only transfer: **24.8 KB → 2.3 KB br**.

### Not in this PR: merging small chunks

esbuild has no minimum chunk size and no manual chunk grouping. 37 of
the 58 preloaded chunks are under 4 KB, and 19 are under 1 KB. In an
experiment, rolldown 1.2.15 with default splitting gave 21 static
imports instead of 58 and 419,654 B br instead of 473,724 B, with the
route splitting from #2734/#2738 kept. That needs the client build moved
from tsup to rolldown and checked at runtime, so it is a separate
follow-up.

### Screenshots (mock conversations, 1440×900, dark)

The screenshots should look the same. Fonts loaded before: `Inter
400/500/600/700, Outfit 500` from Google. After: `Inter Variable
100–900, Outfit Variable 100–900` from the assets prefix.

| before | after |
|---|---|
| ![before
transcript](https://junior-prod.sentry.dev/public/artifacts/b4947b78-03e1-436b-a63f-8b927028f578.png)
| ![after
transcript](https://junior-prod.sentry.dev/public/artifacts/0c11e4d0-ca99-440a-aa2d-268baac25b4d.png)
|
| ![before
conversations](https://junior-prod.sentry.dev/public/artifacts/7c910c02-c24f-4ce1-8b63-0c3585b7d3af.png)
| ![after
conversations](https://junior-prod.sentry.dev/public/artifacts/e9b34c90-cb15-47ea-ab11-2a7ffa9b82b0.png)
|

Header avatar at 4× zoom, PNG (left) and WebP (right):

![avatar
compare](https://junior-prod.sentry.dev/public/artifacts/2b9a421c-4cec-4214-a2f4-e56151d3d0e4.png)

### Checks

- `pnpm test:e2e:dashboard` (playwright, local chromium): 100 passed
- `pnpm --filter @sentry/junior-dashboard test`: 370 passed, 1 failed.
The failure is `dashboard-output.test.ts`. It also fails on clean `main`
in this sandbox: the nitro build reports `MISSING_EXPORT
nitroIntegration` from a hoisted `@sentry/[email protected]`. CI
should run it.
- `nitro-plugin-module.test.ts` and `app-config.test.ts`: 42 passed
- typecheck (dashboard, core), dashboard and core oxlint, `file-length`,
`dashboard-style`, `test-architecture`, `package:lint`, and the pre-push
`pnpm lint`: pass

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Afbc3c9e7ecae9c7dc9aa0a400563ce91 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/agent%3Afbc3c9e7ecae9c7dc9aa0a400563ce91/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 5c34c777 Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant