Skip to content

Commit de9118b

Browse files
committed
errors: support possible deletion of globalThis.Error
Do not crash trying to access prepareStackTrace on `undefined`.
1 parent db4e701 commit de9118b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const maybeOverridePrepareStackTrace = (globalThis, error, trace) => {
8181
// https://crbug.com/v8/7848
8282
// `globalThis` is the global that contains the constructor which
8383
// created `error`.
84-
if (typeof globalThis.Error.prepareStackTrace === 'function') {
84+
if (typeof globalThis.Error?.prepareStackTrace === 'function') {
8585
return globalThis.Error.prepareStackTrace(error, trace);
8686
}
8787
// We still have legacy usage that depends on the main context's `Error`

0 commit comments

Comments
 (0)