feat: replace custom error page with Astro's built-in error overlay#8
Merged
feat: replace custom error page with Astro's built-in error overlay#8
Conversation
… overlay
Use Astro's built-in ErrorOverlay Web Component instead of the custom 7-file
ErrorPage implementation. Errors are now sent via WebSocket and rendered by
the patched Vite client, providing source highlighting, hints, and editor links
out of the box.
- Remove `hmr: { overlay: false }` from Vite config
- Inline `renderComponentByPath` into the render success path
- Replace catch block with minimal HTML + WebSocket error payload
- Remove `MightyDevOptions` type (use `MightyServerOptions` everywhere)
- Delete `packages/core/src/dev/components/error-page/` (7 files)
- Update tests to match new error handling behavior
…ment Pass through loc, hint, frame, fullCode, plugin, pluginCode, id, and cause from the original error to the WebSocket payload. Astro's module loader intercepts hot.send() and calls collectErrorMetadata() + getViteErrorPayload() to enrich the overlay — but only if these properties are present. Without them, the overlay was missing source code highlighting, error carets, and hints.
…location Astro's collectInfoFromStacktrace heuristic searches for a line containing "src" or "node_modules" — but when the error message itself contains a component path (e.g., "astro/src/pages/index.astro"), it matches the message line instead of an actual stack frame, causing loc extraction to fail. Add extractLocFromStack() that only parses proper "at ..." stack frames, and use it as a fallback when the error doesn't already have loc set. This ensures the overlay always shows the "Open in editor" link.
…Stack Add `title` to the WebSocket error payload — AstroError instances carry a `title` property that the overlay uses for the main heading (falls back to "An error occurred." when missing). Remove `extractLocFromStack` — for errors like PrerenderClientAddressNotAvailable, the extracted loc would point to an internal Astro file (render-context.js), which isn't useful to the user. Let the interceptor's collectErrorMetadata handle loc extraction naturally.
(do not show external files)
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.
Uh oh!
There was an error while loading. Please reload this page.