Skip to content

Fix page-ssr CSS 404s on incrementally cached API pages - #2247

Open
David Pine (IEvangelist) wants to merge 1 commit into
mainfrom
ievangelist-fix-page-ssr-css-404
Open

David Pine (IEvangelist) wants to merge 1 commit into
mainfrom
ievangelist-fix-page-ssr-css-404

Conversation

@IEvangelist

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: ea8b396ac827b1948a26d74b991b622d76fd06b4

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ New regression test fails without the patch and passes with it.
↑ Existing incremental reuse/invalidation test still passes.
↓ Full site build and CI not yet observed.
↓ Pages whose sheets change now re-render, so a warm build after a safelist change is slower.
Diagnosis confidence 9/10 ↑ Live API package pages link page-ssr.Dm8KbnAz.css (404) while other pages link page-ssr.BCTXfwVA.css, both at deployed commit a01bf08.
↑ The two CSS files differ only by one icon class (fsharp) from network icon data.
↑ Astro's skip check ignores emitted stylesheets.
Evidence fit 8/10 ↑ Reproduced the exact symptom in a fixture: restored page links a stylesheet the new build didn't emit.
↓ Internal production pipeline logs and cache state weren't inspected.

Summary

API reference pages on aspire.dev request /_astro/page-ssr.Dm8KbnAz.css, which returns 404. Other pages at the same deployed commit (a01bf08) link page-ssr.BCTXfwVA.css, which exists.

Cause: starlight-plugin-icons fetches icon data from the network at build time, and UnoCSS turns the resulting safelist into the page-ssr stylesheet. UnoCSS fills that CSS after Vite transforms modules, so Astro's incremental-build route dependency hash doesn't see it change. API routes return a cacheKey that covers only the API document and deployment metadata. When the icon data changed between two builds of the same commit, cached API pages were restored with a link to the previous build's stylesheet, which the new build no longer emitted.

Fix: patches/astro@7.4.1.patch now folds the stylesheets each page links (pageData.styles) into its route dependency hash. A page whose emitted CSS changes is re-rendered, and unchanged pages are still reused. Astro 7.4.12 has the same gap.

The live site stays broken until production is rebuilt with this change or with a cleared Astro build cache.

Third-party links and affiliations

None

Validation

  • vitest run --config vitest.config.ts tests/unit/incremental-build.vitest.test.ts: before the patch, the new test failed with the production symptom (the restored page linked compiler.DnzRRV--.css while the build emitted compiler.aYXAaYXT.css). With the patch, both tests pass.
  • vitest run --config vitest.config.ts tests/unit/api-cache-key.vitest.test.ts tests/unit/build-performance.vitest.test.ts: passed (16 tests).
  • eslint tests/unit/incremental-build.vitest.test.ts: passed.
  • Not run locally: full bun run build (left to CI).

UnoCSS fills its page-ssr stylesheet after transform, so Astro's route
dependency hash missed changes to it. When the icon safelist (fetched
from the network at build time) changed between builds of one commit,
restored API reference pages kept linking a page-ssr.*.css that the new
build no longer emitted, causing 404s in production.

Fold each page's emitted stylesheets into its dependency hash.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 00:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The changed Astro prerender-cache contract cannot be independently verified from this snapshot, and fixture results do not cover the full-site stylesheet graph or production rebuilds with a restored cache.

No open issues 🎉

What changed in this PR

This PR prevents cached API reference pages from linking to missing CSS files after incremental builds on aspire.dev.

Changes:

  • Extends Astro’s route dependency hash to include emitted stylesheets, invalidating cached pages when their CSS changes.
  • Adds regression coverage for stylesheet changes and continued cache reuse when stylesheets stay unchanged.
  • Documents the additional purpose of the Astro patch.
File Description
src/​frontend/​tests/​unit/​incremental-build.vitest.test.ts Adds a UnoCSS fixture testing stylesheet invalidation and unchanged-page reuse.
src/​frontend/​patches/​README.md Explains how the Astro patch prevents stale stylesheet links.
src/​frontend/​patches/​astro@7.4.1.patch Includes external stylesheet URLs and inline CSS in route dependency hashes.

Review effort: Balanced

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #2247. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #2247 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

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