fix(astro): include styles in custom 500 error pages#14488
Merged
florian-lefebvre merged 8 commits intowithastro:mainfrom Oct 8, 2025
Merged
fix(astro): include styles in custom 500 error pages#14488florian-lefebvre merged 8 commits intowithastro:mainfrom
florian-lefebvre merged 8 commits intowithastro:mainfrom
Conversation
Fixes issue where custom `500.astro` pages did not include their styles when rendered dynamically in SSR mode. ### Root Cause Error pages like `500.astro` were not always added to the SSR `pageMap` when `pageData2` was missing from `internals.pagesByKeys`. This prevented Vite from importing the page during build, so CSS was never collected into the manifest. ### Changes - Modified `plugin-ssr.ts` to always add pages to `pageMap`, even if `pageData2` is undefined - Added fallback to use `pageData.component` in those cases - Extended `custom-500` fixture to include inline styles - Added regression test: verifies that styles from `500.astro` are included in SSR output (checks minified CSS) ### Impact - Ensures custom 500 error pages behave consistently with other routes - Fix is build-time only; no runtime overhead - Custom `500.astro` remains optional — if missing, Astro still falls back to default error overlay Closes withastro#13272
🦋 Changeset detectedLatest commit: 853ef25 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #14488 will not alter performanceComparing Summary
Footnotes |
Contributor
Author
|
The CI failure looks unrelated to this change (flaky test in dev/restart.test.js). |
Member
|
Hi! Can you undo all the changesets deletions? |
Contributor
Author
restored |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes issue where custom
500.astropages did not include their styles when rendered dynamically in SSR mode.Root Cause
Error pages like
500.astrowere not always added to the SSRpageMapwhenpageData2was missing frominternals.pagesByKeys.This prevented Vite from importing the page during build, so CSS was never collected into the manifest.
Changes
plugin-ssr.tsto always add pages topageMap, even ifpageData2is undefinedpageData.componentin those casescustom-500fixture to include inline styles500.astroare included in SSR output (checks minified CSS)Impact
500.astroremains optional — if missing, Astro still falls back to default error overlayCloses #13272
Changes
Testing
test/custom-500.test.jspnpm test)Docs