From dc1becd15c0b6a6e2f801d11d3220efec9129390 Mon Sep 17 00:00:00 2001 From: Jorge Tarrero Date: Wed, 9 Sep 2020 11:29:32 +0200 Subject: [PATCH 1/2] Fix logger error serializer when the exception stack is not set --- lib/utils/logger.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utils/logger.js b/lib/utils/logger.js index f47f9634..946bc159 100644 --- a/lib/utils/logger.js +++ b/lib/utils/logger.js @@ -9,7 +9,9 @@ module.exports = class Logger { const { LOG_LEVEL, NODE_ENV } = process.env; const logLevelFromNodeEnv = NODE_ENV === 'test' ? 'fatal' : 'info'; const errorSerializer = DEV_ENVS.includes(NODE_ENV) ? err : wrapErrorSerializer(err => { - err.stack = err.stack.split('\n').slice(0, 3).join('\n'); + if (err.hasOwnProperty('stack')) { + err.stack = err.stack.split('\n').slice(0, 3).join('\n'); + } return err; }); const options = { From e039204638f4fc7751c885d8ef64ca5ca983492e Mon Sep 17 00:00:00 2001 From: Jorge Tarrero Date: Wed, 9 Sep 2020 11:42:34 +0200 Subject: [PATCH 2/2] Fix linter --- lib/utils/logger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/logger.js b/lib/utils/logger.js index 946bc159..de076c16 100644 --- a/lib/utils/logger.js +++ b/lib/utils/logger.js @@ -9,7 +9,7 @@ module.exports = class Logger { const { LOG_LEVEL, NODE_ENV } = process.env; const logLevelFromNodeEnv = NODE_ENV === 'test' ? 'fatal' : 'info'; const errorSerializer = DEV_ENVS.includes(NODE_ENV) ? err : wrapErrorSerializer(err => { - if (err.hasOwnProperty('stack')) { + if (Object.prototype.hasOwnProperty.call(err, 'stack')) { err.stack = err.stack.split('\n').slice(0, 3).join('\n'); } return err;