Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java services for firestore not shut down properly when running with database #4657

Closed
jzabinski-dolios opened this issue Jun 16, 2022 · 2 comments

Comments

@jzabinski-dolios
Copy link

jzabinski-dolios commented Jun 16, 2022

[REQUIRED] Environment info

Firebase 10.8.0

firebase-tools:
10.8.0

Platform:
macOS 11.6.6, VSCode 1.68.0

[REQUIRED] Test case

This issue involves workflow/configuration, not code.

[REQUIRED] Steps to reproduce

  1. Download the Firebase Tools.
  2. Open a macOS terminal. Navigate to a folder in which you want to configure Firebase.
  3. Run firebase init to initialize Firebase for the folder. Make sure to configure Firestore and Realtime Database.
  4. In the terminal, start both the firestore emulator and database emulator. firebase emulators:start --only firestore,database should be sufficient.
  5. Open Activity Monitor (or Task Manager in Windows): note that 2 'java' processes are running. Note the PIDs.
  6. Close the terminal via the X button.
  7. Go back to Activity Monitor. Notice that one PID eventually ends, but the other doesn't.
  8. Open a new terminal, as in step 3. Run firebase emulators:start --only firestore,database again.

You should see the error 'Could not start Firestore Emulator, port taken.'

[REQUIRED] Expected behavior

All supporting java services should be closed when the terminal closes.

[REQUIRED] Actual behavior

The Firestore java service does not close properly.

A few things I noticed:

  • These java processes only appear for Firestore and Realtime Database. This issue does not reproduce when other products are emulated (such as Functions).
  • This issue only reproduces when Firestore and Realtime Database run together. When Firestore or Database emulators run separately, the java process closes correctly. (This leads me to guess that this is a bug.)

Closing supporting java processes when VSCode closes was originally misunderstood to be a missing feature in firebase-tools, and was filed as case 10184797. (Just for reference)

This problem was originally noticed when running the emulators in a VSCode terminal, but this issue also reproduces using a plain macOS terminal, so to provide a minimally reproducible example, just the plain terminal was used. Usually, I use the VSCode terminal to run the Firebase emulators. Having to remember to close the emulators separately via ALT+C before closing VSCode generally is inconvenient and easily forgotten. (It is also easily forgotten when running the emulators through a normal terminal.) It is also apparently unnecessary when running firestore or database alone. Note that VSCode has no way to automate running a script when closing a process due to their lack of event when closing VSCode, so we can't work around the issue by extending VSCode, to my knowledge.

FirebaseLog.txt
firebaseJSON.txt

@jzabinski-dolios jzabinski-dolios changed the title Java services for firestore not shut down properly when running in VSCode Terminals with database Java services for firestore not shut down properly when running with database Jun 16, 2022
@Psycarlo
Copy link

Psycarlo commented Aug 8, 2022

Environment Info

  • Windows
  • Firebase --version 11.5.0
  • Java -version java version "18.0.2"

About

Everytime I start or exec emulators, a java window opens:

Aug 08, 2022 10:32:31 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://localhost:65343
API endpoint: http://localhost:8081
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=localhost:8081

Dev App Server is now running.

It does not close automatically.

This started happening when I updated firebase-tools and java version

@yuchenshi
Copy link
Member

@jzabinski-dolios Thanks for reporting this! Please follow this thread for the discussion: #3578 (comment)

@Psycarlo You're running into a separate issue #3871 here. Please subscribe there for updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants