Skip to content

Commit

Permalink
Ensure expando properties are copied
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Oct 23, 2024
1 parent 378c213 commit 336ac6a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/next/src/server/patch-error-inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ export function patchErrorInspect() {
// TODO: Ensure `class MyError extends Error {}` prints `MyError` as the name
newError.stack = parseAndSourceMap(this)

for (const key in this) {
if (!Object.prototype.hasOwnProperty.call(newError, key)) {
// @ts-expect-error -- We're copying all enumerable properties.
// So they definitely exist on `this` and obviously have no type on `newError` (yet)
newError[key] = this[key]
}
}

const originalCustomInspect = (newError as any)[inspectSymbol]
// Prevent infinite recursion.
// { customInspect: false } would result in `error.cause` not using our inspect.
Expand Down

0 comments on commit 336ac6a

Please sign in to comment.