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 <natemoo-re@users.noreply.github.com>
This commit is contained in:
wulinsheng123 2022-12-08 21:12:22 +08:00 committed by GitHub
parent fe0da0185a
commit 2c836b9d12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Error reporting fails on undefined error index

View file

@ -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) {