From a2d0979ffbdaee5cd6fc2c9a8aa958821a6716d8 Mon Sep 17 00:00:00 2001 From: Darkripper214 Date: Sun, 4 Apr 2021 21:55:53 +0800 Subject: [PATCH] lib: remove redundant branch in async_hooks The if-else is check if e.stack is string according to Node.js docs, e.stack is always a string, so there is no need for this check Refs: https://github.com/nodejs/node/issues/38077 --- lib/internal/async_hooks.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 43ba749cd69946..def420b7ebaa31 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -4,7 +4,7 @@ const { ArrayPrototypePop, ArrayPrototypeSlice, ArrayPrototypeUnshift, - ErrorCaptureStackTrace, + FunctionPrototypeBind, ObjectPrototypeHasOwnProperty, ObjectDefineProperty, @@ -158,14 +158,7 @@ function executionAsyncResource() { // Used to fatally abort the process if a callback throws. function fatalError(e) { - if (typeof e.stack === 'string') { - process._rawDebug(e.stack); - } else { - const o = { message: e }; - ErrorCaptureStackTrace(o, fatalError); - process._rawDebug(o.stack); - } - + process._rawDebug(e.stack); const { getOptionValue } = require('internal/options'); if (getOptionValue('--abort-on-uncaught-exception')) { process.abort();