From 39983cc349bbf103ba8b15c45d7f3f32fc095ebb Mon Sep 17 00:00:00 2001 From: danilo batista queiroz Date: Mon, 18 Sep 2023 13:05:07 -0300 Subject: [PATCH] new Error() to call prepareStackTrace --- lib/bunyan.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/bunyan.js b/lib/bunyan.js index 405cdb24..dfc5f31b 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -183,10 +183,10 @@ function getCaller3Info() { var obj = {}; var saveLimit = Error.stackTraceLimit; var savePrepare = Error.prepareStackTrace; - Error.stackTraceLimit = 3; + Error.stackTraceLimit = 4; Error.prepareStackTrace = function (_, stack) { - var caller = stack[2]; + var caller = stack[3]; if (sourceMapSupport) { caller = sourceMapSupport.wrapCallSite(caller); } @@ -197,7 +197,8 @@ function getCaller3Info() { obj.func = func; }; Error.captureStackTrace(this, getCaller3Info); - this.stack; + const err = new Error(); + err.stack; Error.stackTraceLimit = saveLimit; Error.prepareStackTrace = savePrepare;