Skip to content

Commit

Permalink
errors: support possible deletion of globalThis.Error
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
targos authored and BethGriggs committed Oct 13, 2020
1 parent e8434d8 commit 3c90b1a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const maybeOverridePrepareStackTrace = (globalThis, error, trace) => {
// https://crbug.com/v8/7848
// `globalThis` is the global that contains the constructor which
// created `error`.
if (typeof globalThis.Error.prepareStackTrace === 'function') {
if (typeof globalThis.Error?.prepareStackTrace === 'function') {
return globalThis.Error.prepareStackTrace(error, trace);
}
// We still have legacy usage that depends on the main context's `Error`
Expand Down

0 comments on commit 3c90b1a

Please sign in to comment.