From 39a45b0aec9f02f232a06321ea4deae32fb467bf Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Sat, 21 Oct 2023 03:20:37 -0700 Subject: [PATCH] chore: improve process exit cleanup --- packages/daemon/src/util/process.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/daemon/src/util/process.ts b/packages/daemon/src/util/process.ts index 530260ba..90ffb0e1 100644 --- a/packages/daemon/src/util/process.ts +++ b/packages/daemon/src/util/process.ts @@ -1,5 +1,6 @@ import { PUBLIC_DEBUG } from '$constants' import { LoggerService } from '@pockethost/common' +import { gracefulExit } from 'exit-hook' ;['unhandledRejection', 'uncaughtException'].forEach((type) => { process.on(type, (e) => { const { error } = LoggerService().create(type) @@ -7,7 +8,8 @@ import { LoggerService } from '@pockethost/common' error(`${e}`) if (PUBLIC_DEBUG) { - throw e + console.error(e.stack) + gracefulExit() } }) })