Open quantuminformation opened 4 years ago
Same on Linux with firebase-tools:8.2.0
If I run firebase emulators:start
for the first time I see normal expected output:
╰─$ firebase emulators:start 1 ↵
i emulators: Starting emulators: functions, firestore, database, hosting, pubsub
✔ hub: emulator hub started at http://localhost:4400
✔ functions: functions emulator started at http://localhost:5001
<...>
But then I press CTRL+C
seems that some resources are not cleaned-up (no msg about stopping emulators)
If I try to run firebase emulators:start
for the 2nd time I see output with warning:
╰─$ firebase emulators:start 130 ↵
i emulators: Starting emulators: functions, firestore, database, hosting, pubsub
⚠ emulators: It seems that you are running multiple instances of the emulator suite for project my-project. This may result in unexpected behavior.
✔ hub: emulator hub started at http://localhost:4400
✔ functions: functions emulator started at http://localhost:5001
<...>
I start command firebase emulators:start --only functions,firestore,database
╰─$ firebase emulators:start --only functions,firestore,database 1 ↵
i emulators: Starting emulators: functions, firestore, database
✔ hub: emulator hub started at http://localhost:4400
✔ functions: functions emulator started at http://localhost:5001
<...>
Then I press CTRL+C
I see printed out message about emulators being stopped
i emulators: Shutting down emulators.
i hub: Stopping emulator hub
i functions: Stopping functions emulator
i firestore: Stopping firestore emulator
i database: Stopping database emulator
I can repeat this as many times, and never see It seems that you are running multiple instances<...>
warning
Maybe only one type of emulator is not being stopped which is not in my --only functions,firestore,database
list. I haven't tested this much. But maybe this help to find root cause.
I restarted my system and this error went away, close ticket?
No. Run firebase emulators:start
two time and you will get this warning again
worked ok this time
@audkar it seems that the real bug in your situation is Ctrl+C is not always causing a clean shutdown.
@QuantumInformation what happens is each time you start up the emulator hub it writes a "locator" file to /${os.tmpdir()}/hub-${projectId}.json
. So on a linux machine that might be /tmp/hub-project123.json
. It uses this file so that cross-process commands like emulators:export
can find each other.
If you ever run into this problem and can't get rid of it, it's safe to delete that file manually.
it seems that the real bug in your situation is Ctrl+C is not always causing a clean shutdown.
@samtstern Jup. To summarize my previous comment:
CTRL+C
on firebase emulators:start
command exits instantaneously (without printing emulators: Shutting down emulators. <...>
)CTRL+C
on firebase emulators:start --only functions,firestore,database
prints emulators: Shutting down emulators.
message and takes a second to exit to shell.Is this not reproducible on your machine?
Oh. I see. On my project hosting
emulator doesn't start. I issue CTRL-C
command before
✔ emulators: All emulators started, it is now safe to connect.
And then state is not cleared properly. Next time I try to start emulators I get that warning It seems that you are running multiple instances
@audkar oh wow you're totally right, thank you for figuring this out! I will send a PR to fix this.
Oh wait I spoke too soon. I cannot reproduce this on my computer (I thought I could, but it was an error on my side). I am able to shut down cleanly with or without --only
I am able to shut down cleanly with or without --only
@samtstern Yes --only
option is not relevant in this case. If emulators start-up sequence is interrupted with CTRL-C
before all emulators are started successfully:
✔ emulators: All emulators started, it is now safe to connect.
then state is not cleared properly.
Have a fix going here: https://github.com/firebase/firebase-tools/pull/2230
Hey I'm trying to follow this thread but I'm a little lost here. I'm trying to use the emulator and I'm getting the same issue. Has it been fixed in #2230 and I should just wait until it gets added to the firebase tools?
edit: after looking back over this page, it's a different issue in that I can't make the emulator work, period, and so I don't think it can be an instance shutdown issue, as I can't ever get the (firebase) emulator to start.
@Elijer if you're using the latest version of the CLI (8.4.1
) you should not be seeing this often (unless you actually are running multiple copies of the emulator).
The emulator hub creates a sentinel file when it starts up. If it fails to shut down properly, that file can be left behind. When you start the emulators again if the file is already present you will see this warning.
We improved the reliability of the shutdown code to make this happen less often.
@samstern thanks for the quick reply. So I think I'm missing something about npm: when I do npm install -g firebase-tools
I get +firebase-tools@8.4.1
but when I print npm firebase-tools -v
I get 6.14.4
. Sorry I know this isn't how the issues should be used.
I don't think I'm running multiple copies of the emulator, but I might also be missing something there. I don't have any other terminals open that are running any processes. Is there any other way I could have other copies of the emulator running?
How do I find the sentinel file to delete it?
@Elijer hmmm sounds like something is going wrong with your npm
setup. Unfortunately it's pretty hard to guess what that issue is from here.
If you run emulators:start
with the --debug
flag you can look for a log message like this:
[hub] writing locator at <path>
That will tell you where the sentinel file is.
@samstern Hey thanks a lot for your help.
I followed the filepath after using the --debug
flag and deleted the file completely. I still get this:
Elijahs-Air:cafe-infinite jah$ firebase emulators:start
i emulators: Starting emulators: functions, firestore, hosting
⚠ emulators: It seems that you are running multiple instances of the emulator suite for project cafe-infinite. This may result in unexpected behavior.
⚠ Your requested "node" version "8" doesn't match your global version "12"
⚠ firestore: Did not find a Cloud Firestore rules file specified in a firebase.json config file.
⚠ firestore: The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.
i firestore: Firestore Emulator logging to firestore-debug.log
Error: firestore: Firestore Emulator has exited with code: 1
I deleted and reinstalled firebase. Could you point me in a direction? I'm out of ideas.
@Elijer in those logs I don't see any message like this one:
i emulators: Shutting down emulators.
Which implies that you're not using the latest version of the Firebase CLI. What does firebase --version
show you? It should be 8.4.1
if you're on the latest.
@samtstern When I run firebase --version
I get 8.4.1
:/
I made a new project in the console, initiated it into an empty folder on a different user on my computer, and tried using the emulators again. I don't have the console message, but I'm pretty sure there was no ⚠ emulators: It seems that you are running multiple instances of the emulator suite for project agggghh-38157. This may result in unexpected behavior.
That time.
And then, I went into package-lock.json and I changed the firestore port. Again, that warning line was missing:
Elijahs-Air:aggghh Kua$ firebase emulators:start
i emulators: Starting emulators: functions, firestore, hosting
⚠ Your requested "node" version "8" doesn't match your global version "12"
i firestore: Firestore Emulator logging to firestore-debug.log
Error: firestore: Firestore Emulator has exited with code: 1
edit: meant to say 'firebase.json'
Ok it seems like we solved the multiple instances issue. Could you file a new issue for the problem you're seeing with the Firestore emulator. Include the output of emulators:start --debug
On Fri, May 29, 2020 at 10:05 AM Elijah Kennedy notifications@github.com wrote:
@samtstern https://github.com/samtstern When I run firebase --version I get 8.4.1 :/
I made a new project in the console, initiated it into an empty folder on a different user on my computer, and tried using the emulators again. I don't have the console message, but I'm pretty sure there was no ⚠ emulators: It seems that you are running multiple instances of the emulator suite for project agggghh-38157. This may result in unexpected behavior. That time.
And then, I went into package-lock.json and I changed the firestore port. Again, that warning line was missing:
`Elijahs-Air:aggghh Kua$ firebase emulators:start i emulators: Starting emulators: functions, firestore, hosting ⚠ Your requested "node" version "8" doesn't match your global version "12" i firestore: Firestore Emulator logging to firestore-debug.log
Error: firestore: Firestore Emulator has exited with code: 1`
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-tools/issues/2228#issuecomment-635990477, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACATB2RVIL54ZGI62BU7EKDRT66KRANCNFSM4M45V2SQ .
Yeah, I'll start a new issue. To be clear, the
⚠ emulators: It seems that you are running multiple instances of the emulator suite for project firestripe-boilerplate. This may result in unexpected behavior.
still comes up every time afterwards, just not the first time firestore emulators:start
is run after changing the port in the firebase.json, or after initiating a new project.
Okay here's the new issue: https://github.com/firebase/firebase-tools/issues/2307
Couldn't be there an firebase emulators:stop to kill any running emulators?
Edit: this seems closed but still happens here.
I had this problem too, in having instances of the emulator working even after finishing/shut down (Ctrl + C).
So, I used a script on my package.json with all the ports I use in my firebase.json file, and after the shot down I run the script, I believe it can be a good workaround.
package.json
"scripts": {
...
"stopall": "lsof -t -i:2000 -i:6001 -i:9080 -i:8086 -i:9099 | xargs kill -9",
...
}
firebase.json
...
"emulators": {
"hosting": {
"port": 2000
},
"functions": {
"port": 6001
},
"firestore": {
"port": 9080
},
"pubsub": {
"port": 8086
},
"auth": {
"port": 9099
},
"ui": {
"enabled": true
},
}
...
On the project root:
Ctrl + C
npm run stopall
I had this problem too, in having instances of the emulator working even after finishing/shut down (Ctrl + C).
So, I used a script on my package.json with all the ports I use in my firebase.json file, and after the shot down I run the script, I believe it can be a good workaround.
package.json
"scripts": { ... "stopall": "lsof -t -i:2000 -i:6001 -i:9080 -i:8086 -i:9099 | xargs kill -9", ... }
firebase.json
... "emulators": { "hosting": { "port": 2000 }, "functions": { "port": 6001 }, "firestore": { "port": 9080 }, "pubsub": { "port": 8086 }, "auth": { "port": 9099 }, "ui": { "enabled": true }, } ...
On the project root:
Ctrl + C
npm run stopall
That's good! I've been using sudo pkill node and sometimes java, but this may kill other non related processes.
Have the same issue, the npm script is a good workaround
Had the same issue and then read carefully all the messages on the terminal and here. I have a habit of pressing Ctrl + C
a few times to completely kill the local development process. With the emulator suite, you only need to press Ctrl + C
once then wait for all hubs to shut down. When I do Ctrl + C
twice too quickly, some of the processes didn't finish exiting so the emulator is left hanging already when I tried to start the emulator again.
@samtstern this issue is still happening, even in 9.20.0
.
this still happens in 10
@jaredgibb which exact version is the problem happening?
10.1.14 (I think) but after reading through some other threads, I ran the update code from the cli and it fixed the issue. Sorry for not coming back! Thanks for checking in!!
I'm still having the issue in firebase-tools: 10.7.2
@jaredgibb what do you mean by "ran the update code from the cli"? Do you just mean npm install -g firebase-tools@latest
or is there some other update mechanism that I'm not seeing?
Hi folks - I'm running into this issue with firebase-tools: 10.7.2
, which is how I found this thread. Seems like this was fixed a couple of years ago - is this an issue that has re-emerged?
def still happening
I'm also experiencing the issue with version 11.0.1 on Ubuntu.
Also having this issue with version 11.14.1
on Windows 11.
Still happening on version 11.16.0 on Mac OS.
It turns out that a bunch of stuff can kill the process in such a way that the emulators can't shut down gracefully.
I just ran into it with a Turborepo project and also by trying to use the dotenv-cli
with the emulators.
I have to open an entirely different terminal to run the emulators.
For instance dotenv firebase emulators:start --import ./.emulator-data --export-on-exit
won't shutdown correctly and never exports its data.
If I try to run the whole thing under a turbo run dev --parallel
process, it won't shut down correctly. I tried to create a minimal reproduction, and IT DIDN'T REPRODUCE! I can't seem to isolate the difference between my minimal repro case and my production application. I'm losing my mind.
Regardless, the solution appears to be to run the emulators in an entirely different terminal instance. The ctrl+c
command can't be filtered through anything. The emulators cannot be run through a child process.
I am having this problem with version 11.17.0
on macOS Ventura Version 13.0.1
.
I have individually checked each port that was listed as the host and reserved ports for the emulator and manually killed everything running on them, but my local host is still behaving as though the emulator is running.
If I try to start the emulator again I get the error saying it is already running and I am still getting the error on the localhost site that I only get while the emulator is running (due to a UID not existing for my user account in the emulator data yet).
I'm using firebase emulators:start --only firestore --import ./path-to-data --export-on-exit
and ctrl + c
to exit.
I will try some of the ideas others have suggested in their comments.
I have a fix in the works for the pubsub issue but it may not land until January. In the meantime here's an example command to use to kill still-running processes on Linux:
pids=$(ps aux | grep '[p]ubsub' | awk '{print $2}'); if [ ! -z "$pids" ]; then kill $pids; fi;
@christhompsongoogle a simple pkill -f firebase
is working for me on Ubuntu.
i think i have the same problem
my log :
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 emulators: Shutting down emulators.
i ui: Stopping Emulator UI
Terminate batch job (Y/N)?
Error: Storage Emulator Rules runtime exited unexpectedly.
error - uncaughtException: FirebaseError: Storage Emulator Rules runtime exited unexpectedly.
at ChildProcess.<anonymous> (C:\Users\Omar\Desktop\school-bot\school-bot\node_modules\firebase-tools\lib\emulator\storage\rules\runtime.js:96:23)
at ChildProcess.emit (node:events:527:28)
at ChildProcess.emit (node:domain:475:12)
at ChildProcess.cp.emit (C:\Users\Omar\Desktop\school-bot\school-bot\node_modules\cross-spawn\lib\enoent.js:34:29)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
children: [],
context: undefined,
exit: 1,
original: undefined,
status: 500
}
! Emulator UI has exited upon receiving signal: SIGINT
i functions: Stopping Functions Emulator
i hosting: Stopping Hosting Emulator
i firestore: Stopping Firestore Emulator
i hosting: 127.0.0.1 - - [03/Jan/2023:11:53:16 +0000] "GET /_next/image?url=%2FformBackground.png&w=1920&q=75 HTTP/1.1" - - "http://127.0.0.1:5000/school/signUp" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54"
! Firestore Emulator has exited upon receiving signal: SIGINT
i auth: Stopping Authentication Emulator
i storage: Stopping Storage Emulator
i eventarc: Stopping Eventarc Emulator
i hub: Stopping emulator hub
i logging: Stopping Logging Emulator
Any update on this? I am having the issue on 13.2.1, neither pids=$(ps aux | grep '[p]ubsub' | awk '{print $2}'); if [ ! -z "$pids" ]; then kill $pids; fi;
nor pkill -f firebase
worked for me, it still shows ⚠ emulators: It seems that you are running multiple instances of the emulator suite for project hello-world. This may result in unexpected behavior.
.
This issue occurs for me in VS Code 1.86.1 on macOS Sonoma 14.3.1 when using VS Code's tasks (tasks.json) to execute a NPM script (deployDev) which executes a ZSH script which executes firebase emulators:start
. Using CTRL+C to stop the script does not cleanly shutdown Firebase. For now my workaround is to not use tasks. Instead, executing npm run deployDev
directly in the VS Code terminal and using CTRL+C will properly shutdown the firebase emulators.
@Ferezoz - I'm guessing that one of the other emulators is the cause of your issue here - pids=$(ps aux | grep '[p]ubsub' | awk '{print $2}'); if [ ! -z "$pids" ]; then kill $pids; fi
is specific to the pubsub emulator. I recommend you try ps aux
and look for + kill and other emulator processes you find.
@joehan I found that the issue occurs when I run the script using turbo
from the root of my turborepo and the emulator is not able to shut down correctly when I do ctrl+c
, but if I use pnpm or run It from the subworkspace it works and shuts down correctly.
Same issue here...
Same issue here
Same here, i'm using the emulator direct on VS Code terminal via WSL: Ubuntu-22.04
[REQUIRED] Environment info
8.2.0 firebase-tools:
Platform: Macos
[REQUIRED] Test case
https://github.com/QuantumInformation/svelte-fullstack-starter
[REQUIRED] Steps to reproduce
Run
firebase emulators:start
at the root of the above url[REQUIRED] Expected behavior
emulator to start
[REQUIRED] Actual behavior
the following output
debug log: