diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index 74d6575e0a9114..4ee890e9db26d1 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -105,19 +105,14 @@ function createFatalException() { if (er == null || er.domain == null) { try { const report = internalBinding('report'); - if (report != null) { - if (require('internal/options').getOptionValue( - '--experimental-report')) { - const config = {}; - report.syncConfig(config, false); - if (Array.isArray(config.events) && - config.events.includes('exception')) { - if (er) { - report.onUnCaughtException(er.stack); - } else { - report.onUnCaughtException(undefined); - } - } + if (report != null && + require('internal/options') + .getOptionValue('--experimental-report')) { + const config = {}; + report.syncConfig(config, false); + if (Array.isArray(config.events) && + config.events.includes('exception')) { + report.onUnCaughtException(er ? er.stack : undefined); } } } catch {} // NOOP, node_report unavailable.