Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve all error stack lines #4364

Merged
merged 2 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-comics-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Preserve all error stack lines
1 change: 0 additions & 1 deletion packages/astro/src/core/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/core/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Comment on lines -238 to +241
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanErrorStack is removed as it should already be cleaned by collectErrorMetadata.

args.push(``);
}
return args.join('\n');
Expand Down