No graceful exit using NPM Scripts
See original GitHub issue[REQUIRED] Environment info
firebase-tools: 8.6.0
Platform: macOS
[REQUIRED] Test case
Setup a firebase project that uses the emulators.
[REQUIRED] Steps to reproduce
Start the emulators through npm start
. Iβm currently using hosting, functions and firestore.
"start": "GOOGLE_APPLICATION_CREDENTIALS=/google-creds.json firebase emulators:start --import=./data --export-on-exit"
Stop emulators using CTRL-C
[REQUIRED] Expected behavior
A graceful exit.
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 "./data" please wait for the export to finish...
i Found running emulator hub for project emulator-test at http://localhost:4400
i Deleting directory /emulator-test/functions/data/firestore_export
i Exporting data to: /emulator-test/functions/data
i emulators: Received export request. Exporting data to /emulator-test/functions/data.
β emulators: Export complete.
β Export complete
i emulators: Shutting down emulators.
i hub: Stopping emulator hub
i ui: Stopping Emulator UI
i logging: Stopping Logging Emulator
i functions: Stopping Functions Emulator
i firestore: Stopping Firestore Emulator
i hosting: Stopping Hosting Emulator
[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 "./data" please wait for the export to finish...
β emulators: Received SIGINT (Ctrl-C) 2 times. You have forced the Emulator Suite to exit without waiting for 2 subprocesses to finish. These processes may still be running on your machine:
ββββββββββββββββββββββ¬βββββββββββββββββ¬βββββββ
β Emulator β Host:Port β PID β
ββββββββββββββββββββββΌβββββββββββββββββΌβββββββ€
β Emulator UI β localhost:4003 β 1818 β
ββββββββββββββββββββββΌβββββββββββββββββΌβββββββ€
β Firestore Emulator β localhost:4001 β 1818 β
ββββββββββββββββββββββ΄βββββββββββββββββ΄βββββββ
To force them to exit run:
kill 1818 1818
Ironically, with --debug
it does not fail.
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 "./data" please wait for the export to finish...
[2020-07-30T13:06:48.536Z] >>> HTTP REQUEST GET http://localhost:4400/
[2020-07-30T13:06:48.540Z] [worker-~diagnostic~-9bb61cf1-df1d-41d7-9e2a-fba05b969819]: exited {"metadata":{"emulator":{"name":"functions"},"message":"[worker-~diagnostic~-9bb61cf1-df1d-41d7-9e2a-fba05b969819]: exited"}}
[2020-07-30T13:06:48.541Z] [worker-~diagnostic~-9bb61cf1-df1d-41d7-9e2a-fba05b969819]: FINISHED {"metadata":{"emulator":{"name":"functions"},"message":"[worker-~diagnostic~-9bb61cf1-df1d-41d7-9e2a-fba05b969819]: FINISHED"}}
[2020-07-30T13:06:48.546Z] <<< HTTP RESPONSE 200 {"x-powered-by":"Express","content-type":"application/json; charset=utf-8","content-length":"50","etag":"W/\"32-awxJiFDOu9uUeUgx8zcVKrDfcNg\"","date":"Thu, 30 Jul 2020 13:06:48 GMT","connection":"keep-alive"}
i Found running emulator hub for project kja-emulator-example at http://localhost:4400
i Deleting directory /Users/kellyjandrews/Google Drive/Apps/emulator-test/functions/data/firestore_export
i Exporting data to: /Users/kellyjandrews/Google Drive/Apps/emulator-test/functions/data
[2020-07-30T13:06:48.555Z] >>> HTTP REQUEST POST http://localhost:4400/_admin/export
{"path":"/Users/kellyjandrews/Google Drive/Apps/emulator-test/functions/data"}
i emulators: Received export request. Exporting data to /Users/kellyjandrews/Google Drive/Apps/emulator-test/functions/data.
[2020-07-30T13:06:48.579Z] >>> HTTP REQUEST POST http://localhost:4001/emulator/v1/projects/kja-emulator-example:export
{"database":"projects/kja-emulator-example/databases/(default)","export_directory":"/Users/kellyjandrews/Google Drive/Apps/emulator-test/functions/data","export_name":"firestore_export"}
[2020-07-30T13:06:48.695Z] Jul 30, 2020 9:06:48 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
{"metadata":{"emulator":{"name":"firestore"},"message":"Jul 30, 2020 9:06:48 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2020-07-30T13:06:48.729Z] Jul 30, 2020 9:06:48 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.
{"metadata":{"emulator":{"name":"firestore"},"message":"Jul 30, 2020 9:06:48 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected HTTP/2 connection.\n"}}
[2020-07-30T13:06:48.834Z] Jul 30, 2020 9:06:48 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
{"metadata":{"emulator":{"name":"firestore"},"message":"Jul 30, 2020 9:06:48 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2020-07-30T13:06:50.151Z] <<< HTTP RESPONSE 200 {"content-type":"application/json","content-length":"4"}
β emulators: Export complete.
[2020-07-30T13:06:50.154Z] <<< HTTP RESPONSE 200 {"x-powered-by":"Express","content-type":"application/json; charset=utf-8","content-length":"16","etag":"W/\"10-MxB4y4MLcx6QDsp8b8vgp7iFMFo\"","date":"Thu, 30 Jul 2020 13:06:50 GMT","connection":"keep-alive"}
β Export complete
i emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}
i hub: Stopping emulator hub {"metadata":{"emulator":{"name":"hub"},"message":"Stopping emulator hub"}}
i ui: Stopping Emulator UI {"metadata":{"emulator":{"name":"ui"},"message":"Stopping Emulator UI"}}
i logging: Stopping Logging Emulator {"metadata":{"emulator":{"name":"logging"},"message":"Stopping Logging Emulator"}}
i functions: Stopping Functions Emulator {"metadata":{"emulator":{"name":"functions"},"message":"Stopping Functions Emulator"}}
i firestore: Stopping Firestore Emulator {"metadata":{"emulator":{"name":"firestore"},"message":"Stopping Firestore Emulator"}}
i hosting: Stopping Hosting Emulator {"metadata":{"emulator":{"name":"hosting"},"message":"Stopping Hosting Emulator"}}
[2020-07-30T13:06:50.166Z] *** shutting down gRPC server since JVM is shutting down
{"metadata":{"emulator":{"name":"firestore"},"message":"*** shutting down gRPC server since JVM is shutting down\n"}}
β Emulator UI has exited upon receiving signal: SIGINT
[2020-07-30T13:06:50.169Z] *** server shut down
{"metadata":{"emulator":{"name":"firestore"},"message":"*** server shut down\n"}}
[2020-07-30T13:06:50.224Z] File /Users/kellyjandrews/Google Drive/Apps/emulator-test/functions/data/firebase-export-metadata.json changed, reloading triggers {"metadata":{"emulator":{"name":"functions"},"message":"File /Users/kellyjandrews/Google Drive/Apps/emulator-test/functions/data/firebase-export-metadata.json changed, reloading triggers"}}
Not sure why itβs getting the second SIGINT, or if there is any way to prevent it from happening. Let me know if there is something I can change on my end to fix it directly as well. Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
No graceful exit using NPM Scripts that trigger multiple SIGINT
Several CTRL+C are triggered by npm: as far as I can count in my logs, there is one SIGINT for each process chained...
Read more >How to Stop NodeJS process gracefully from npm script
There are several ways to do this. Use pkill : pkill -SIGINT -f server.ts. This way, you do not need to know the...
Read more >Developers - No graceful exit using NPM Scripts - - Bountysource
Coming soon: A brand new website interface for an even better experience!
Read more >node-graceful - npm
node-graceful is a small helper module without dependencies that aims to ease graceful exit of complex node programs including async waitingΒ ...
Read more >Graceful Shutdown in NodeJS - Medium
To exit with a "failure" code use 1 . To get this exit code after shutdown, run this command in the terminal where...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@guillaumeprevost yes please open a new issue with steps to reproduce! The simpler the better.
This seems to have been fixed in August 2020 with : https://github.com/firebase/firebase-tools/pull/2517 https://github.com/firebase/firebase-tools/pull/2415
I donβt know if there was some kind of regression recently, but I have just encountered the issue described in this original issue report.
In my case, adding --debug did not help. I am using the current latest version of firebase-tools v9.2.0.
Here is how I am using it in NodeJS :
Should I post all the details as a comment in this issue or open a new issue ?