Open Soviut opened 2 years ago
An interesting follow up. If I open another terminal and kill port 3000, the port my Vue dev server is running on, the process ends and the currently hanging terminal exits back to the command line with a Killed
message.
npx kill-port 3000
I have been experimenting with this plugin locally and found that these changes seem to allow it to shut down correctly
Remove the following line, we will manually do a clean shutdown later when we detect SIGTERM
// shutdownWhenKilled({})
Remove the monkey patching on the server.close
function.
// patch server.close to close emulators as well
// const { close: closeServer } = server
// server.close = async () => {
// await Promise.all([closeServer(), cleanShutdown()])
// }
Finally, create a shutdown
function that tells firebase to do a clean shutdown, close the vite dev server and exit the process. Run this shutdown on SIGINT
and SIGTERM
events.
const shutdown = async () => {
await cleanShutdown()
await server.close()
// this prevents the process from hanging after server close
process.exit(0)
}
process.on('SIGINT', shutdown)
process.on('SIGTERM', shutdown)
Now, when you hit Ctrl + C to stop the vite dev server, firebase shuts down cleanly and you're returned to the command prompt.
I have a Vite + Vue 3 project. I installed this plugin to simplify the startup but have found that hitting Ctrl+C doesn't exit cleanly.
vite.config.ts
The project starts fine; I see Firebase emulator start without errors. However, when I hit Ctrl+C to exit, I get the normal emulator shut down messages, but I don't get returned to the command prompt; It just hangs. When I hit Ctrl+C again (where the
^C
are), it starts displaying emulator warnings. It still won't return to the command prompt, however.The only way I'm able to exit is by closing the terminal window. This leaves port 3000 open.