From 2948e96afd7fde91ec39bb5434bad93760ccfe13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Z=C3=BCnd?= Date: Tue, 16 Apr 2019 08:55:44 +0200 Subject: [PATCH] util: fix wrong usage of Error.prepareStackTrace The return value of Error.prepareStackTrace will become the result of Error.stack accesses. Setting Error.stack inside this callback relies on the fact that the magic get accessor detects the change in the middle of formatting, and is unnecessary in this instance. Refs: https://github.com/v8/node/pull/96 PR-URL: https://github.com/nodejs/node/pull/27250 Reviewed-By: Ben Noordhuis Reviewed-By: Masashi Hirano Reviewed-By: Ruben Bridgewater Reviewed-By: Gus Caplan Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Anto Aravinth --- lib/internal/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/util.js b/lib/internal/util.js index 82c42e2772d890..14c8baa68c85e6 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -347,7 +347,7 @@ function isInsideNodeModules() { // the perf implications should be okay. getStructuredStack = runInNewContext(`(function() { Error.prepareStackTrace = function(err, trace) { - err.stack = trace; + return trace; }; Error.stackTraceLimit = Infinity;