summaryrefslogtreecommitdiff
path: root/lib/internal/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/util.js')
-rw-r--r--lib/internal/util.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/internal/util.js b/lib/internal/util.js
index e13cce92ff..58502f3b7a 100644
--- a/lib/internal/util.js
+++ b/lib/internal/util.js
@@ -7,7 +7,8 @@ const {
ERR_NO_CRYPTO,
ERR_UNKNOWN_SIGNAL
},
- uvErrmapGet
+ uvErrmapGet,
+ overrideStackTrace,
} = require('internal/errors');
const { signals } = internalBinding('constants').os;
const {
@@ -338,15 +339,13 @@ function isInsideNodeModules() {
// side-effect-free. Since this is currently only used for a deprecated API,
// the perf implications should be okay.
getStructuredStack = runInNewContext(`(function() {
- Error.prepareStackTrace = function(err, trace) {
- return trace;
- };
Error.stackTraceLimit = Infinity;
-
return function structuredStack() {
- return new Error().stack;
+ const e = new Error();
+ overrideStackTrace.set(e, (err, trace) => trace);
+ return e.stack;
};
- })()`, {}, { filename: 'structured-stack' });
+ })()`, { overrideStackTrace }, { filename: 'structured-stack' });
}
const stack = getStructuredStack();