mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
f4797ff1ef
Installing an uncaughtException listener has a side effect that process is not aborted. This is quite bad for monitoring/logging tools which tend to be interested in errors but don't want to cause side effects like swallow an exception or change the output on console. There are some workarounds in the wild like monkey patching emit or rethrow in the exception if monitoring tool detects that it is the only listener but this is error prone and risky. This PR allows to install a listener to monitor uncaughtException without the side effect to consider the exception has handled. PR-URL: https://github.com/nodejs/node/pull/31257 Refs: https://github.com/nodejs/node/pull/30932 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
12 lines
240 B
JavaScript
12 lines
240 B
JavaScript
'use strict';
|
|
|
|
// Keep the event loop alive.
|
|
setTimeout(() => {}, 1e6);
|
|
|
|
process.on('uncaughtExceptionMonitor', (err) => {
|
|
console.log(`Monitored: ${err.message}, will throw now`);
|
|
missingFunction();
|
|
});
|
|
|
|
throw new Error('Shall exit');
|