From a2251340f95f8a98ddf7e91a9a235ae7bde58470 Mon Sep 17 00:00:00 2001 From: Gareth George Date: Thu, 15 Jun 2023 23:53:32 +0000 Subject: [PATCH] Fix Cloud Functions fails to close gracefully when exit code is a string --- src/invoker.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/invoker.ts b/src/invoker.ts index be32130c..6d33f8a1 100644 --- a/src/invoker.ts +++ b/src/invoker.ts @@ -100,7 +100,10 @@ export class ErrorHandler { sendCrashResponse({err, res: latestRes, callback: killInstance}); }); - process.on('exit', code => { + process.on('exit', (code: number | string) => { + if (typeof code === 'string') { + code = parseInt(code); + } sendCrashResponse({ err: new Error(`Process exited with code ${code}`), res: latestRes,