From 163a30728b5d53b767b05b1d4f6c57116bb737bc Mon Sep 17 00:00:00 2001 From: Ben Gourley Date: Mon, 8 Jan 2018 18:24:20 +0000 Subject: [PATCH] Prevent duplicate log for undelivered error, fixes #123 --- lib/bugsnag.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/bugsnag.js b/lib/bugsnag.js index 7b13a97..02f2050 100644 --- a/lib/bugsnag.js +++ b/lib/bugsnag.js @@ -66,8 +66,12 @@ function autoNotifyCallback(notifiedError, uncaughtError) { errorMsg.push("configuration options prevent the following error from being sent to Bugsnag."); errorMsg.push("https://docs.bugsnag.com/platforms/nodejs/other/configuration-options/#notifyreleasestages"); } - errorMsg.push(""); - errorMsg.push(notifiedError.stack); + // only print caught errors at this point. uncaught errors get printed by + // the onUncaughtError function later so this prevents duplicate logs + if (!(Configuration.onUncaughtError && uncaughtError)) { + errorMsg.push(""); + errorMsg.push(notifiedError.stack); + } } errorMsg.push(""); Configuration.logger.error(errorMsg.join('\n'));