Firebase-tools: firebase emulators:exec fails to kill the firestore emulator

Created on 4 Jun 2019  Â·  13Comments  Â·  Source: firebase/firebase-tools

I've been trying to run our tests on circleci and managed to get them top run, but circleci keeps reporting them as failing, despite them succeeding.

The problem is that the step that runs our tests:
./node_modules/.bin/firebase emulators:exec "yarn --ignore-engines test_ci"

exits with: "Error: firestore: firestore: Unable to terminate emulator process (PID=200)"

I've executed the above command on 2 different mac machines and it fails on them as well.

the emulator is acutually killed few seconds after the error is displayed. I guess that this is a timing issue?

we use firebase-tools 6.10.0 and @firebase/testing 0.10.0

Author Feedback closed-by-bot emulator-suite bug

Most helpful comment

Whenever firebase functions throwns an unhandled error w/c closes the emulator, the process is not cleanup up.

by default, it uses port 8080, so checked that the java process is not yet closed. So basically just stop the process using
pkill java

and restart the emulator

All 13 comments

@compojoom I have seen this issue too but not reliably, I am going to move this over to firebase-tools.

well, for me it happens in 99% of the cases. I've seen it complete without error, but unfortunately most of the time it spills out that error.

@compojoom yeah I used to be able to get this reliably on one of my machines, but now I can't get it to happen anywhere!

Some questions:

  • What emulators are started (you can tell by reading the logs)? Is it just Firestore or are others started as well?
  • If you run firebase emulators:start and then wait for them all to start and then kill the process using Ctrl+C do you see the same error?

ctrl+c kills the emulators. The problem is that on CI server I can't start the emulators and then run to the next step. I have to use emulators:exec - and this is where it fails.

The functions and firestore emulator are running:

✔  functions: Emulator started at http://localhost:5001
i  firestore: Logging to firestore-debug.log
✔  firestore: Emulator started at http://localhost:8080
i  firestore: For testing set FIREBASE_FIRESTORE_EMULATOR_ADDRESS=localhost:8080

and then after mocha --exit I get:

✔  Script exited successfully (code 0)
i  Shutting down emulators.
i  Stopping functions emulator
i  Stopping firestore emulator

Error: firestore: firestore: Unable to terminate emulator process (PID=200)
Exited with code 1

just for info - tested it with 6.11 and the same problem persist.

Huh, this is so strange, @samstern, can't we just send all child processes a hard kill command when we're ready to finish?

@compojoom I haven't seen this in a long time (I used to see it occasionally). Do you still see it?


Hey @compojoom. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!


Since there haven't been any recent updates here, I am going to close this issue.

@compojoom if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

Whenever firebase functions throwns an unhandled error w/c closes the emulator, the process is not cleanup up.

by default, it uses port 8080, so checked that the java process is not yet closed. So basically just stop the process using
pkill java

and restart the emulator

Similar issue:

I Found jest wasn't exiting during the firebase emulators:exec command. Appending the following options helped it exit and the emulator to terminate:

firebase emulators:exec "jest --forceExit --detectOpenHandles"

More info here:
https://jestjs.io/docs/en/cli.html#--forceexit

I have the same problem with jest but the only emulator I have a problem with is the pubsub one. Even with the options from @benwinding .
If I run twice my tests, it appear to have a emulator error telling me that port is already taken. If I look to windows process manager, I have a java process to kill if I want to make it work again.

I'm on windows 10 and firebase-tools 8.1.1

I have the same problem with jest but the only emulator I have a problem with is the pubsub one. Even with the options from @benwinding .
If I run twice my tests, it appear to have a emulator error telling me that port is already taken. If I look to windows process manager, I have a java process to kill if I want to make it work again.

I'm on windows 10 and firebase-tools 8.1.1

I was able to go around this issue by doing the following:

  1. run the following from the command line
    _netstat -a -o -n_
    this will list the processes, find out which one is using port 8085 or whatever port you configured for pubsub

  2. run the following from the command line to kill that process.
    _taskkill /F /PID 2940_

2940 is the process ID identified above

  1. Start the emulator(s) again
    _firebase emulators:start._

Regards,

Was this page helpful?
0 / 5 - 0 ratings