summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/late-spoons-knock.md5
-rw-r--r--packages/astro/src/core/errors/dev/utils.ts2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/late-spoons-knock.md b/.changeset/late-spoons-knock.md
new file mode 100644
index 000000000..0cca6ce61
--- /dev/null
+++ b/.changeset/late-spoons-knock.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Fixes an issue where CLI commands could not report the reason for failure before exiting.
diff --git a/packages/astro/src/core/errors/dev/utils.ts b/packages/astro/src/core/errors/dev/utils.ts
index a61d1ee47..f5de83de4 100644
--- a/packages/astro/src/core/errors/dev/utils.ts
+++ b/packages/astro/src/core/errors/dev/utils.ts
@@ -174,7 +174,7 @@ function collectInfoFromStacktrace(error: SSRError & { stack: string }): StackIn
stackText.split('\n').find((ln) => ln.includes('src') || ln.includes('node_modules'));
// Disable eslint as we're not sure how to improve this regex yet
// eslint-disable-next-line regexp/no-super-linear-backtracking
- const source = possibleFilePath?.replace(/^[^(]+\(([^)]+).*$/, '$1').replace(/^\s+at\s+/, '');
+ const source = possibleFilePath?.replace?.(/^[^(]+\(([^)]+).*$/, '$1').replace(/^\s+at\s+/, '');
let file = source?.replace(/:\d+/g, '');
const location = /:(\d+):(\d+)/.exec(source!) ?? [];