diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index b11f54b35d6253..3691f8f9189453 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.