merge: Fix uncaught exception hooks and add more shutdown logging. (!1111)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1111

Approved-by: Marie <github@yuugi.dev>
Approved-by: dakkar <dakkar@thenautilus.net>
This commit is contained in:
dakkar 2025-06-13 07:14:28 +00:00
commit 99bf315351
5 changed files with 27 additions and 9 deletions

View file

@ -64,17 +64,35 @@ async function main() {
}
// Display detail of uncaught exception
process.on('uncaughtException', err => {
process.on('uncaughtExceptionMonitor', ((err, origin) => {
try {
logger.error('Uncaught exception:', err);
logger.error(`Uncaught exception (${origin}):`, err);
} catch {
console.error('Uncaught exception:', err);
console.error(`Uncaught exception (${origin}):`, err);
}
});
}));
// Dying away...
process.on('disconnect', () => {
try {
logger.warn('IPC channel disconnected! The process may soon die.');
} catch {
console.warn('IPC channel disconnected! The process may soon die.');
}
});
process.on('beforeExit', code => {
try {
logger.warn(`Event loop died! Process will exit with code ${code}.`);
} catch {
console.warn(`Event loop died! Process will exit with code ${code}.`);
}
});
process.on('exit', code => {
logger.info(`The process is going to exit with code ${code}`);
try {
logger.info(`The process is going to exit with code ${code}`);
} catch {
console.info(`The process is going to exit with code ${code}`);
}
});
//#endregion

View file

@ -101,7 +101,7 @@ async function watchSrc() {
process.on('SIGHUP', resolve);
process.on('SIGINT', resolve);
process.on('SIGTERM', resolve);
process.on('uncaughtException', reject);
process.on('uncaughtExceptionMonitor', reject);
process.on('exit', resolve);
}).finally(async () => {
await context.dispose();

View file

@ -99,7 +99,7 @@ async function watchSrc() {
process.on('SIGHUP', resolve);
process.on('SIGINT', resolve);
process.on('SIGTERM', resolve);
process.on('uncaughtException', reject);
process.on('uncaughtExceptionMonitor', reject);
process.on('exit', resolve);
}).finally(async () => {
await context.dispose();

View file

@ -100,7 +100,7 @@ async function watchSrc() {
process.on('SIGHUP', resolve);
process.on('SIGINT', resolve);
process.on('SIGTERM', resolve);
process.on('uncaughtException', reject);
process.on('uncaughtExceptionMonitor', reject);
process.on('exit', resolve);
}).finally(async () => {
await context.dispose();

View file

@ -99,7 +99,7 @@ async function watchSrc() {
process.on('SIGHUP', resolve);
process.on('SIGINT', resolve);
process.on('SIGTERM', resolve);
process.on('uncaughtException', reject);
process.on('uncaughtExceptionMonitor', reject);
process.on('exit', resolve);
}).finally(async () => {
await context.dispose();