diff --git a/changelog.txt b/changelog.txt index 732c563ae74..62da11444cf 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,4 @@ * Fixes a bug where the functions emulator did not work with `firebase-functions` versions `3.x.x`. * Make the Functions emulator automatically point to the RTDB emulator when running. -* Auto-download Firestore and RTDB emulators when using `emulators:start`. \ No newline at end of file +* Fixes issue where the functions runtime would not always exit on success (#1346). +* Auto-download Firestore and RTDB emulators when using `emulators:start`. diff --git a/src/emulator/functionsEmulatorRuntime.ts b/src/emulator/functionsEmulatorRuntime.ts index 09057b176ab..f7ab1fd37a1 100644 --- a/src/emulator/functionsEmulatorRuntime.ts +++ b/src/emulator/functionsEmulatorRuntime.ts @@ -959,8 +959,12 @@ async function main(): Promise { } if (require.main === module) { - main().catch((err) => { - new EmulatorLog("FATAL", "runtime-error", err.stack ? err.stack : err).log(); - process.exit(); - }); + main() + .then(() => { + process.exit(0); + }) + .catch((err) => { + new EmulatorLog("FATAL", "runtime-error", err.stack ? err.stack : err).log(); + process.exit(1); + }); }