firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 917 forks source link

Error: It seems that you are running multiple instances of the emulator suite #2228

Open quantuminformation opened 4 years ago

quantuminformation commented 4 years ago

[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

image

debug log:

svelte-fullstack-starter git:(master) firebase emulators:start --debug
[2020-05-09T19:44:10.572Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-05-09T19:44:10.574Z] > authorizing via signed-in user
i  emulators: Starting emulators: functions, firestore, database, hosting, pubsub
⚠  emulators: It seems that you are running multiple instances of the emulator suite for project svelte-fullstack-starter. This may result in unexpected behavior.
[2020-05-09T19:44:10.593Z] [hub] writing locator at /var/folders/wk/xpjrzzgj0937n2ys2j951wyr0000gn/T/hub-svelte-fullstack-starter.json
✔  hub: emulator hub started at http://localhost:4400
⚠  Your requested "node" version "8" doesn't match your global version "12"
✔  functions: functions emulator started at http://localhost:5002
⚠  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.
[2020-05-09T19:44:10.875Z] Ignoring unsupported arg: projectId
[2020-05-09T19:44:10.875Z] Ignoring unsupported arg: auto_download
[2020-05-09T19:44:10.875Z] Starting firestore emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/Users/nikos/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.3.jar","--host","localhost","--port",8080,"--functions_emulator","localhost:5002"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false}
i  firestore: firestore emulator logging to firestore-debug.log
[2020-05-09T19:44:11.974Z] API endpoint: http://localhost:
[2020-05-09T19:44:11.974Z] 8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=localhost:8080

Dev App Server is now running.

✔  firestore: firestore emulator started at http://localhost:8080
i  firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
⚠  database: Did not find a Realtime Database rules file specified in a firebase.json config file.
⚠  database: 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.
[2020-05-09T19:44:12.158Z] Ignoring unsupported arg: projectId
[2020-05-09T19:44:12.158Z] Ignoring unsupported arg: auto_download
[2020-05-09T19:44:12.158Z] Starting database emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/Users/nikos/.cache/firebase/emulators/firebase-database-emulator-v4.4.1.jar","--host","localhost","--port",9000,"--functions_emulator_host","localhost","--functions_emulator_port",5002],"optionalArgs":["port","host","functions_emulator_port","functions_emulator_host"],"joinArgs":false}
i  database: database emulator logging to database-debug.log
[2020-05-09T19:44:13.695Z] 21:44:13.694 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started

[2020-05-09T19:44:13.874Z] 21:44:13.873 [main] INFO com.firebase.server.forge.App$ - Listening at localhost:9000

✔  database: database emulator started at http://localhost:9000
i  database: For testing set FIREBASE_DATABASE_EMULATOR_HOST=localhost:9000
[2020-05-09T19:44:13.950Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[2020-05-09T19:44:13.950Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
 <request body omitted>
[2020-05-09T19:44:14.125Z] <<< HTTP RESPONSE 200 {"content-type":"application/json; charset=utf-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","date":"Sat, 09 May 2020 19:44:14 GMT","server":"scaffolding on HTTPServer2","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-27=\":443\"; ma=2592000,h3-25=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q049=\":443\"; ma=2592000,h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2020-05-09T19:44:14.137Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/svelte-fullstack-starter/webApps/-/config

[2020-05-09T19:44:14.786Z] <<< HTTP RESPONSE 200 {"content-type":"application/json; charset=UTF-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","date":"Sat, 09 May 2020 19:44:14 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-27=\":443\"; ma=2592000,h3-25=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q049=\":443\"; ma=2592000,h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5000
✔  hosting: hosting emulator started at http://localhost:5000
[2020-05-09T19:44:14.811Z] Ignoring unsupported arg: projectId
[2020-05-09T19:44:14.811Z] Ignoring unsupported arg: auto_download
[2020-05-09T19:44:14.811Z] Starting pubsub emulator with command {"binary":"/Users/nikos/.cache/firebase/emulators/pubsub-emulator-0.1.0/pubsub-emulator/bin/cloud-pubsub-emulator","args":["--host=localhost","--port=8085"],"optionalArgs":["port","host"],"joinArgs":true}
i  pubsub: pubsub emulator logging to pubsub-debug.log
[2020-05-09T19:44:14.985Z] This is the Google Pub/Sub fake.

[2020-05-09T19:44:14.986Z] Implementation may be incomplete or differ from the real system.

[2020-05-09T19:44:15.015Z] May 09, 2020 9:44:14 PM com.google.cloud.pubsub.testing.v1.Main main
INFO: IAM integration is disabled. IAM policy methods and ACL checks are not supported

[2020-05-09T19:44:15.547Z] May 09, 2020 9:44:15 PM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
INFO: Unable to apply Java 7 long hostname workaround.

[2020-05-09T19:44:15.630Z] May 09, 2020 9:44:15 PM com.google.cloud.pubsub.testing.v1.Main main
INFO: Server started, listening on 8085

✔  pubsub: pubsub emulator started at http://localhost:8085
i  functions: Watching "/Users/nikos/WebstormProjects/svelte-fullstack-starter/functions" for Cloud Functions...
[2020-05-09T19:44:15.845Z] [worker-pool] addWorker(~diagnostic~)
[2020-05-09T19:44:15.846Z] [worker-pool] Adding worker with key ~diagnostic~, total=1
[2020-05-09T19:44:15.846Z] [worker-pool] submitWork(triggerId=)
[2020-05-09T19:44:15.847Z] [worker-~diagnostic~-d5e3219e-99af-4c9f-85e3-90482760af04]: Assigning socketPath: /var/folders/wk/xpjrzzgj0937n2ys2j951wyr0000gn/T/fire_emu_31830.sock
[2020-05-09T19:44:15.847Z] [worker-~diagnostic~-d5e3219e-99af-4c9f-85e3-90482760af04]: BUSY
[2020-05-09T19:44:15.991Z] May 09, 2020 9:44:15 PM io.gapi.emulators.grpc.GrpcServer$3 operationComplete
INFO: Adding handler(s) to newly registered Channel.

[2020-05-09T19:44:16.076Z] [runtime-status] [31830] Functions runtime initialized. {"cwd":"/Users/nikos/WebstormProjects/svelte-fullstack-starter/functions","node_version":"12.13.1"}
[2020-05-09T19:44:16.077Z] [runtime-status] [31830] Disabled runtime features: undefined
[2020-05-09T19:44:16.080Z] [runtime-status] [31830] Resolved module firebase-admin {"declared":true,"installed":true,"version":"8.12.1","resolution":"/Users/nikos/WebstormProjects/svelte-fullstack-starter/functions/node_modules/firebase-admin/lib/index.js"}
[2020-05-09T19:44:16.082Z] [runtime-status] [31830] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.6.1","resolution":"/Users/nikos/WebstormProjects/svelte-fullstack-starter/functions/node_modules/firebase-functions/lib/index.js"}
[2020-05-09T19:44:16.082Z] [runtime-status] [31830] Set PUBSUB_EMULATOR_HOST to localhost:8085
[2020-05-09T19:44:16.085Z] [runtime-status] [31830] Outgoing network have been stubbed. [{"name":"http","status":"mocked"},{"name":"http","status":"mocked"},{"name":"https","status":"mocked"},{"name":"https","status":"mocked"},{"name":"net","status":"mocked"}]
[2020-05-09T19:44:16.133Z] [runtime-status] [31830] Checked functions.config() {"config":{}}
[2020-05-09T19:44:16.133Z] [runtime-status] [31830] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.6.1","resolution":"/Users/nikos/WebstormProjects/svelte-fullstack-starter/functions/node_modules/firebase-functions/lib/index.js"}
[2020-05-09T19:44:16.134Z] [runtime-status] [31830] Resolved module firebase-admin {"declared":true,"installed":true,"version":"8.12.1","resolution":"/Users/nikos/WebstormProjects/svelte-fullstack-starter/functions/node_modules/firebase-admin/lib/index.js"}
[2020-05-09T19:44:16.134Z] [runtime-status] [31830] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.6.1","resolution":"/Users/nikos/WebstormProjects/svelte-fullstack-starter/functions/node_modules/firebase-functions/lib/index.js"}
[2020-05-09T19:44:16.134Z] [runtime-status] [31830] firebase-admin has been stubbed. {"adminResolution":{"declared":true,"installed":true,"version":"8.12.1","resolution":"/Users/nikos/WebstormProjects/svelte-fullstack-starter/functions/node_modules/firebase-admin/lib/index.js"}}
[2020-05-09T19:44:16.137Z] [runtime-status] [31830] initializeApp(DEFAULT) {"databaseURL":"https://svelte-fullstack-starter.firebaseio.com","storageBucket":"svelte-fullstack-starter.appspot.com","projectId":"svelte-fullstack-starter"}
✔  functions[listUsers]: http function initialized (http://localhost:5002/svelte-fullstack-starter/us-central1/listUsers).
✔  functions[upsertUsername]: http function initialized (http://localhost:5002/svelte-fullstack-starter/us-central1/upsertUsername).
✔  emulators: All emulators started, it is now safe to connect.
[2020-05-09T19:44:16.139Z] [worker-~diagnostic~-d5e3219e-99af-4c9f-85e3-90482760af04]: IDLE
audkar commented 4 years ago

Same on Linux with firebase-tools:8.2.0

Start/Stop all emulators command shows warning after repeated use.

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
<...>

Start/Stop --only emulators command works as expected after repeated use.

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.

quantuminformation commented 4 years ago

I restarted my system and this error went away, close ticket?

audkar commented 4 years ago

No. Run firebase emulators:start two time and you will get this warning again

quantuminformation commented 4 years ago

worked ok this time

image

samtstern commented 4 years ago

@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.

audkar commented 4 years ago

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:

  1. Pressing CTRL+C on firebase emulators:start command exits instantaneously (without printing emulators: Shutting down emulators. <...>)
  2. Pressing 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?

audkar commented 4 years ago

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

samtstern commented 4 years ago

@audkar oh wow you're totally right, thank you for figuring this out! I will send a PR to fix this.

samtstern commented 4 years ago

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

audkar commented 4 years ago

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.

samtstern commented 4 years ago

Have a fix going here: https://github.com/firebase/firebase-tools/pull/2230

Elijer commented 4 years ago

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.

samtstern commented 4 years ago

@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.

Elijer commented 4 years ago

@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?

samtstern commented 4 years ago

@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.

Elijer commented 4 years ago

@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.

samtstern commented 4 years ago

@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.

Elijer commented 4 years ago

@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'

samtstern commented 4 years ago

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 .

Elijer commented 4 years ago

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.

Elijer commented 4 years ago

Okay here's the new issue: https://github.com/firebase/firebase-tools/issues/2307

SrBrahma commented 3 years ago

Couldn't be there an firebase emulators:stop to kill any running emulators?

Edit: this seems closed but still happens here.

AlexBrasileiro commented 3 years ago

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:

SrBrahma commented 3 years ago

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.

ir-fuel commented 3 years ago

Have the same issue, the npm script is a good workaround

Dara-To commented 2 years ago

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.

JamesVanWaza commented 2 years ago

@samtstern this issue is still happening, even in 9.20.0.

jaredgibb commented 2 years ago

this still happens in 10

JamesVanWaza commented 2 years ago

@jaredgibb which exact version is the problem happening?

jaredgibb commented 2 years ago

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!!

nayfin commented 2 years ago

I'm still having the issue in firebase-tools: 10.7.2

nayfin commented 2 years ago

@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?

rlacatus commented 2 years ago

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?

MiguelNiblock commented 2 years ago

def still happening

pascalbe-dev commented 1 year ago

I'm also experiencing the issue with version 11.0.1 on Ubuntu.

emmanuelmahove commented 1 year ago

Also having this issue with version 11.14.1 on Windows 11.

ntofigzade commented 1 year ago

Still happening on version 11.16.0 on Mac OS.

deltaepsilon commented 1 year ago

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.

Hannah-Robson commented 1 year ago

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.

christhompsongoogle commented 1 year ago

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;

laurentpayot commented 1 year ago

@christhompsongoogle a simple pkill -f firebase is working for me on Ubuntu.

omarqra commented 1 year ago

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
Ferezoz commented 5 months ago

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..

velocd commented 4 months ago

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.

joehan commented 4 months ago

@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.

Ferezoz commented 4 months ago

@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.

sebastianrueckerai commented 4 months ago

Same issue here...

servefast-cto commented 1 month ago

Same issue here

AlexVFornazieri commented 1 month ago

Same here, i'm using the emulator direct on VS Code terminal via WSL: Ubuntu-22.04