From 13be78dee82a6fe3891f15210350fb22c7df76d9 Mon Sep 17 00:00:00 2001 From: James Murdza Date: Mon, 30 Sep 2024 02:55:22 -0700 Subject: [PATCH] fix: don't exit the script when exceptions occur --- backend/server/src/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index 0a4fc72..c4ee2e0 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -39,6 +39,18 @@ import { saveFileRL, } from "./ratelimit"; +process.on('uncaughtException', (error) => { + console.error('Uncaught Exception:', error); + // Do not exit the process + // You can add additional logging or recovery logic here +}); + +process.on('unhandledRejection', (reason, promise) => { + console.error('Unhandled Rejection at:', promise, 'reason:', reason); + // Do not exit the process + // You can also handle the rejected promise here if needed +}); + dotenv.config(); const app: Express = express();