From 8dcc7ac2833b4f9687d2d7b37bae11ea0984ac0f Mon Sep 17 00:00:00 2001 From: Mark Stosberg Date: Wed, 6 Jul 2016 10:21:20 -0400 Subject: [PATCH] Add code comment to explain conditional throw on unCaught exceptions --- lib/instrumentation/core/globals.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/instrumentation/core/globals.js b/lib/instrumentation/core/globals.js index f7bfd52917..e7ae9da1f1 100644 --- a/lib/instrumentation/core/globals.js +++ b/lib/instrumentation/core/globals.js @@ -21,6 +21,8 @@ function initialize(agent) { process.on('uncaughtException', function __NR_uncaughtExceptionHandler(error) { agent.errors.add(null, error) agent.tracer.segment = null + // If we are the only listener, follow the best practice of re-throwing the error + // Otherwise, do nothing to be sure the other listener has a chance to run. if (listenerCount(process, 'uncaughtException') < 2) { throw error }