diff --git a/packages/backend/src/boot/entry.ts b/packages/backend/src/boot/entry.ts index e52d77ab9b..afb48e526c 100644 --- a/packages/backend/src/boot/entry.ts +++ b/packages/backend/src/boot/entry.ts @@ -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 diff --git a/packages/frontend-shared/build.js b/packages/frontend-shared/build.js index 9941114757..f3a94fe364 100644 --- a/packages/frontend-shared/build.js +++ b/packages/frontend-shared/build.js @@ -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(); diff --git a/packages/misskey-bubble-game/build.js b/packages/misskey-bubble-game/build.js index 5d534cc6fd..93a695e649 100644 --- a/packages/misskey-bubble-game/build.js +++ b/packages/misskey-bubble-game/build.js @@ -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(); diff --git a/packages/misskey-js/build.js b/packages/misskey-js/build.js index b794592815..76a95fb3f5 100644 --- a/packages/misskey-js/build.js +++ b/packages/misskey-js/build.js @@ -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(); diff --git a/packages/misskey-reversi/build.js b/packages/misskey-reversi/build.js index 5d534cc6fd..93a695e649 100644 --- a/packages/misskey-reversi/build.js +++ b/packages/misskey-reversi/build.js @@ -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();