From f5f71094ec74961b4cca2ee451798abd830c617a Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Fri, 8 Nov 2024 16:07:40 +0100 Subject: [PATCH] fix: error overlay message escape (#12305) Co-authored-by: Princesseuh <3019731+Princesseuh@users.noreply.github.com> --- .changeset/breezy-plums-clap.md | 5 +++++ packages/astro/src/core/errors/dev/vite.ts | 2 ++ packages/astro/src/core/module-loader/vite.ts | 21 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 .changeset/breezy-plums-clap.md diff --git a/.changeset/breezy-plums-clap.md b/.changeset/breezy-plums-clap.md new file mode 100644 index 0000000000..d6d3f4b26a --- /dev/null +++ b/.changeset/breezy-plums-clap.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a case where the error overlay would not escape the message diff --git a/packages/astro/src/core/errors/dev/vite.ts b/packages/astro/src/core/errors/dev/vite.ts index 56688877a8..9063e45b70 100644 --- a/packages/astro/src/core/errors/dev/vite.ts +++ b/packages/astro/src/core/errors/dev/vite.ts @@ -105,6 +105,7 @@ export function enhanceViteSSRError({ } export interface AstroErrorPayload { + __isEnhancedAstroErrorPayload: true; type: ErrorPayload['type']; err: Omit & { name?: string; @@ -164,6 +165,7 @@ export async function getViteErrorPayload(err: ErrorWithMetadata): Promise { + events.emit('hmr-error', { + type: 'error', + err: { + message: payload.err.message, + stack: payload.err.stack, + }, + }); + + args[0] = payload; + _wsSend.apply(this, args); + }); + return; + } events.emit('hmr-error', msg); } _wsSend.apply(this, args);