Skip to content

No graceful exit using NPM Scripts that trigger multiple SIGINT #3034

@guillaumeprevost

Description

@guillaumeprevost

This issue appeared already last year (issue #2507) and was resolved in August 2020 by the following PRs :
#2415
#2517

However, I experience the issue now with firebase-tools latest version.

[REQUIRED] Environment info

firebase-tools: 9.2.0 (latest at the time of posting)

Platform: Windows (Using Git Bash so commands such as rm, mv ... are available)

[REQUIRED] Test case

Set up a Firebase project that uses the emulators.

[REQUIRED] Steps to reproduce

Use npm to run the project, with several processes chained by &&

Start the emulators through npm start :

"start": "npm run build && firebase emulators:start --import=./emulators-data-import --export-on-exit=./emulators-data",

Stop emulators using CTRL-C

Several CTRL+C are triggered by npm: as far as I can count in my logs, there is one SIGINT for each process chained : the more you add, the more SIGINT are sent through npm.

Note that this happens regardless of whether we specify --import and/or --export, but the issue is about the behavior of Firebase Emulators when it happens

From what I understand in my research and from the comments in #2507, is an NPM issue but Firebase should mitigate it by preventing multiple SIGINT to interrupt a graceful exit.

[REQUIRED] Expected behavior

A graceful exit, all processes being properly stopped, and the the data exported correctly to the specified folder.

i  emulators: Received SIGINT (Ctrl-C) for the first time. Starting a clean shutdown.
i  emulators: Please wait for a clean shutdown or send the SIGINT (Ctrl-C) signal again to stop right now.
i  Automatically exporting data using --export-on-exit "./emulators-data" please wait for the export to finish...        
i  Found running emulator hub for project devstorybee at http://localhost:4400
i  Creating export directory C:\dev\storybee\back\emulators-data
i  Exporting data to: C:\dev\storybee\back\emulators-data
i  emulators: Received export request. Exporting data to C:\dev\storybee\back\emulators-data.
+  emulators: Export complete.
+  Export complete
i  emulators: Shutting down emulators.
i  ui: Stopping Emulator UI
!  Emulator UI has exited upon receiving signal: SIGINT
i  functions: Stopping Functions Emulator
i  hosting: Stopping Hosting Emulator
i  firestore: Stopping Firestore Emulator
!  Firestore Emulator has exited upon receiving signal: SIGINT
i  auth: Stopping Authentication Emulator
i  hub: Stopping emulator hub
i  logging: Stopping Logging Emulator

Terminate batch job (Y/N)?

[REQUIRED] Actual behavior


i  emulators: Received SIGINT (Ctrl-C) for the first time. Starting a clean shutdown.
i  emulators: Please wait for a clean shutdown or send the SIGINT (Ctrl-C) signal again to stop right now.
i  Automatically exporting data using --export-on-exit "./emulators-data" please wait for the export to finish...
i  Found running emulator hub for project devstorybee at http://localhost:4400
i  Creating export directory C:\dev\storybee\back\emulators-data
i  Exporting data to: C:\dev\storybee\back\emulators-data
Terminate batch job (Y/N)? i  emulators: Received export request. Exporting data to C:\dev\storybee\back\emulators-data.
Terminate batch job (Y/N)? Terminate batch job (Y/N)? Terminate batch job (Y/N)? Terminate batch job (Y/N)? Terminate batch job (Y/N)? +  emulators: Export complete.
+  Export complete
i  emulators: Shutting down emulators.
i  ui: Stopping Emulator UI
!  Emulator UI has exited upon receiving signal: SIGINT
i  functions: Stopping Functions Emulator
i  hosting: Stopping Hosting Emulator
i  firestore: Stopping Firestore Emulator

!  emulators: Received SIGINT (Ctrl-C) 2 times. You have forced the Emulator Suite to exit without waiting for 1 subprocess to finish. These processes may still be running on your machine:

┌────────────────────┬────────────────┬──────┐
│ Emulator           │ Host:Port      │ PID  │
├────────────────────┼────────────────┼──────┤
│ Firestore Emulator │ localhost:8080 │ 4020 │
└────────────────────┴────────────────┴──────┘

To force them to exit run:

TASKKILL /PID 4020 /T

^C^C^C^C^C

The behavior is amplified here : we can see there are 7 SIGINT : with the first, the emulators do what is expected, starting a clean exit. With the second, the exit (and export) gets interrupted and shutdown, the 5 other SIGINT are shown as ^C .

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions