Skip to content

Commit 3c90b1a

Browse files
targosBethGriggs
authored andcommitted
errors: support possible deletion of globalThis.Error
Do not crash trying to access prepareStackTrace on `undefined`. PR-URL: #35499 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Shingo Inoue <[email protected]>
1 parent e8434d8 commit 3c90b1a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/errors.js

+1-1
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)