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`.
  • Loading branch information
targos committed Oct 4, 2020
1 parent db4e701 commit de9118b
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 de9118b

Please sign in to comment.