From de9118b8706141eb81ccb837bfbca04a481f02b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 28 Sep 2020 15:57:45 +0200 Subject: [PATCH] errors: support possible deletion of globalThis.Error Do not crash trying to access prepareStackTrace on `undefined`. --- lib/internal/errors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 314c06c7b78f03..9c5087cf1d2fe0 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -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`