Skip to content

feat: replace custom error page with Astro's built-in error overlay#8

Merged
aminevg merged 8 commits intomainfrom
refactor/use-astro-error-overlay
Mar 19, 2026
Merged

feat: replace custom error page with Astro's built-in error overlay#8
aminevg merged 8 commits intomainfrom
refactor/use-astro-error-overlay

Conversation

@aminevg
Copy link
Contributor

@aminevg aminevg commented Mar 16, 2026

  • Replaces our custom error handling implementation with Astro's error overlay (core)
  • Passes calls to Vite's /__open-in-editor endpoint to the Vite middleware (hono)

aminevg added 8 commits March 16, 2026 14:38
… 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)
@aminevg aminevg changed the title refactor(core): replace custom error page with Astro's built-in error overlay feat: replace custom error page with Astro's built-in error overlay Mar 19, 2026
@aminevg aminevg merged commit fbd4c9e into main Mar 19, 2026
3 checks passed
@aminevg aminevg deleted the refactor/use-astro-error-overlay branch March 19, 2026 13:55
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