From 2c836b9d1283a0707128d172e92ee2bba767486c Mon Sep 17 00:00:00 2001 From: wulinsheng123 <409187100@qq.com> Date: Thu, 8 Dec 2022 21:12:22 +0800 Subject: [PATCH] fix: Error reporting fails on undefined error index (#5539) * fix: Error reporting fails on undefined error index * fix: add changeset * Update .changeset/slow-cherries-bake.md Co-authored-by: Nate Moore --- .changeset/slow-cherries-bake.md | 5 +++++ packages/astro/src/core/errors/dev/utils.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/slow-cherries-bake.md diff --git a/.changeset/slow-cherries-bake.md b/.changeset/slow-cherries-bake.md new file mode 100644 index 000000000..ed2837ca0 --- /dev/null +++ b/.changeset/slow-cherries-bake.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Error reporting fails on undefined error index diff --git a/packages/astro/src/core/errors/dev/utils.ts b/packages/astro/src/core/errors/dev/utils.ts index a36ffc8d8..6bcdaba6e 100644 --- a/packages/astro/src/core/errors/dev/utils.ts +++ b/packages/astro/src/core/errors/dev/utils.ts @@ -20,7 +20,7 @@ export const incompatPackageExp = new RegExp(`(${Object.keys(incompatiblePackage * Useful for consistent reporting regardless of where the error surfaced from. */ export function collectErrorMetadata(e: any, rootFolder?: URL | undefined): ErrorWithMetadata { - const err = AggregateError.is(e) ? (e.errors as SSRError[]) : [e as SSRError]; + const err = AggregateError.is(e) || Array.isArray((e as any).errors) ? (e.errors as SSRError[]) : [e as SSRError]; err.forEach((error) => { if (error.stack) {