diff --git a/lib/internal/util.js b/lib/internal/util.js index b92e4c5b588479..953b1ce0f577e5 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -390,17 +390,16 @@ function isInsideNodeModules() { // Use `runInNewContext()` to get something tamper-proof and // side-effect-free. Since this is currently only used for a deprecated API, // the perf implications should be okay. - getStructuredStack = runInNewContext('(' + function() { + getStructuredStack = runInNewContext(`(function() { Error.prepareStackTrace = function(err, trace) { err.stack = trace; }; Error.stackTraceLimit = Infinity; return function structuredStack() { - // eslint-disable-next-line no-restricted-syntax return new Error().stack; }; - } + ')()', {}, { filename: 'structured-stack' }); + })()`, {}, { filename: 'structured-stack' }); } const stack = getStructuredStack();