Treat unhandled errors as fatal

All possible Promise rejections and exception bubbling should be handled
by either the code creating the exception or the code invoking the
operation that could fail.  Treat therefore uncaught exceptions and
unhandled promise rejetions as fatal errors that log a traceback and
immedately terminate the Node.js process.
This commit is contained in:
Hornwitser committed 2023-02-16 01:52:42 +01:00
1 parent 27633d51b6
commit 50703f8ae6
4 files changed
+17 -3

No files matched your search

+1 -3
View File
@@ -284,6 +284,7 @@ async function initialize() {
format: new libLoggingUtils.TerminalFormat(),
}));
}
libLoggingUtils.handleUnhandledErrors(logger);
let command = parameters.args._[0];
if (command === "run") {
@@ -355,9 +356,6 @@ async function startup() {
// and as the process name in ps/top on linux.
process.title = "clusterioMaster";
// add better stack traces on promise rejection
process.on("unhandledRejection", err => logger.error(`Unhandled rejection:\n${err.stack}`));
let { args, shouldRun, clusterLogger, pluginInfos, masterConfigPath, masterConfig } = await initialize();
if (!shouldRun) {
return;