From 77b068086d923e99eb693d1c57b7d6cd906a1e8a Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 18 Aug 2022 14:36:31 +0800 Subject: [PATCH] Preserve all error stack lines (#4364) --- .changeset/rare-comics-roll.md | 5 +++++ packages/astro/src/core/errors.ts | 1 - packages/astro/src/core/messages.ts | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changeset/rare-comics-roll.md diff --git a/.changeset/rare-comics-roll.md b/.changeset/rare-comics-roll.md new file mode 100644 index 000000000000..0f7e7b8b03aa --- /dev/null +++ b/.changeset/rare-comics-roll.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Preserve all error stack lines diff --git a/packages/astro/src/core/errors.ts b/packages/astro/src/core/errors.ts index f7ddd1f9f9c4..d96fbe88540f 100644 --- a/packages/astro/src/core/errors.ts +++ b/packages/astro/src/core/errors.ts @@ -37,7 +37,6 @@ export interface ErrorWithMetadata { export function cleanErrorStack(stack: string) { return stack .split(/\n/g) - .filter((l) => /^\s*at/.test(l)) .map((l) => l.replace(/\/@fs\//g, '/')) .join('\n'); } diff --git a/packages/astro/src/core/messages.ts b/packages/astro/src/core/messages.ts index 855db55fc265..0c74f8cbed0a 100644 --- a/packages/astro/src/core/messages.ts +++ b/packages/astro/src/core/messages.ts @@ -18,7 +18,7 @@ import type { AddressInfo } from 'net'; import os from 'os'; import { ZodError } from 'zod'; import type { AstroConfig } from '../@types/astro'; -import { cleanErrorStack, ErrorWithMetadata } from './errors.js'; +import { ErrorWithMetadata } from './errors.js'; import { emoji, getLocalAddress, padMultilineString } from './util.js'; const PREFIX_PADDING = 6; @@ -235,10 +235,10 @@ export function formatErrorMessage(err: ErrorWithMetadata, args: string[] = []): args.push(red(padMultilineString(err.frame, 4))); } if (args.length === 1 && err.stack) { - args.push(dim(cleanErrorStack(err.stack))); + args.push(dim(err.stack)); } else if (err.stack) { args.push(` ${bold('Stacktrace:')}`); - args.push(dim(cleanErrorStack(err.stack))); + args.push(dim(err.stack)); args.push(``); } return args.join('\n');