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 <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
  • 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
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.