From 4b208f44b55444058e153c32873c63e2c6a7f16a Mon Sep 17 00:00:00 2001 From: Yanlong Wang Date: Sun, 21 Apr 2024 10:17:05 +0800 Subject: [PATCH] fix: process not quitting on errors --- backend/functions/src/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/functions/src/index.ts b/backend/functions/src/index.ts index 629af38..cc42b7e 100644 --- a/backend/functions/src/index.ts +++ b/backend/functions/src/index.ts @@ -23,5 +23,17 @@ process.on('unhandledRejection', (err) => { return; } + // Looks like Firebase runtime does not handle error properly. + // Make sure to quit the process. + process.nextTick(() => process.exit(1)); + + throw err; +}); + +process.on('uncaughtException', (err) => { + // Looks like Firebase runtime does not handle error properly. + // Make sure to quit the process. + process.nextTick(() => process.exit(1)); + throw err; });