firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

starting emulators opens a java window that isn't directly controlled by emulators

Open markgoho opened this issue 4 years ago • 11 comments

[REQUIRED] Environment info

firebase-tools: 9.21.0

java 17.0.1 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)

Platform: Windows 11

[REQUIRED] Test case

want to start emulators

[REQUIRED] Steps to reproduce

start emulators see java window open stop emulators see java window remain open re-start emulators see error about ports in use

[REQUIRED] Expected behavior

emulators can be run without spawning java window

[REQUIRED] Actual behavior

emulators run and spawn java window but don't have control over the process

Video showing behavior: https://www.loom.com/share/bc86030a8e224f70a740e4e0d89d5598

markgoho avatar Oct 28 '21 17:10 markgoho

I've had the exact same issue, but on Windows 10 and firebase-tools: 10.1.0 "Fixed" the issue by switching to OpenJDK @ https://adoptium.net/?variant=openjdk8 Quite annoying, as if the window was not closed the emulator could not start, because ports were in use, and also broke precommit hooks (running emulator in one of the steps caused everything to hung).

DKorosec avatar Jan 19 '22 21:01 DKorosec

"Fixed" the issue by switching to OpenJDK @ https://adoptium.net/?variant=openjdk8

This is not an option going forward given that next firebase-tools versions will require java 11 or superior

I've had the exact same issue, but on Windows 10 and firebase-tools: 10.1.0

Same here with windows 10, java 17 and firebase tools 10.6.0

The windows is from firestore and has the following output


Apr 10, 2022 8:14:38 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://localhost:56350
API endpoint: http://localhost:8082
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=localhost:8082

Dev App Server is now running.

blikblum avatar Apr 10 '22 23:04 blikblum

"Fixed" the issue by switching to OpenJDK @ https://adoptium.net/?variant=openjdk8

This is not an option going forward given that next firebase-tools versions will require java 11 or superior

I've had the exact same issue, but on Windows 10 and firebase-tools: 10.1.0

Same here with windows 10, java 17 and firebase tools 10.6.0

The windows is from firestore and has the following output


Apr 10, 2022 8:14:38 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://localhost:56350
API endpoint: http://localhost:8082
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=localhost:8082

Dev App Server is now running.

Then go for Open JDK 17, I'm using it and it works fine (https://adoptium.net/?variant=openjdk17).

DKorosec avatar Apr 11 '22 08:04 DKorosec

Also happens with firebase-tools 10.1.5 and jdk-18.

In my case, there are 2 unwanted java windows:

  • One with "Dev App Server is now running." message.
  • Other with "This is the Google Pub/Sub fake."

Really annoying.

Corchoneitor avatar Jul 25 '22 03:07 Corchoneitor

Seems like this is an issue specific to Java 17 and Windows users; if someone in the open source community has more context on this, we'd happily accept/review any PRs

lisajian avatar Jul 25 '22 20:07 lisajian

Why was this closed? I still have this issue

Windows: Windows 10 Pro Firebase Tools: v11.15.0

I fixed by installing: https://adoptium.net/temurin/releases/?version=17 And restarting my machine

Psycarlo avatar Oct 26 '22 18:10 Psycarlo

hey @Psycarlo I don't think the issue was closed -- and I'm still experiencing it too!

it looks like (per this comment) the OpenJDK version doesn't do this.

markgoho avatar Oct 26 '22 20:10 markgoho

This is a hack, but I was able to get it to exit by setting detached to false. I don't know about export-on-exit as I haven't used it.

https://github.com/firebase/firebase-tools/blob/master/src/emulator/downloadableEmulators.ts#L365-L369

ishowta avatar Nov 01 '22 11:11 ishowta

Just to add some data points.

  • No popup with JDK 11.0.15 🎉
  • Popup with JDK 11.0.17 🐛

After rollback, everything is fine again.

(Windows 10 + Oracle JDKs, tested with both firebase 10.6.0 and 11.19.0)

Also, in terms of export-on-exit behavior. Closing the popup prevents the export on exit to happen. Detached=false will lead to an error during export, preventing it as well.

Wadeck avatar Jan 01 '23 14:01 Wadeck

I did some investigation and this seems to be caused by a bug in node's child_process.spawn function:

https://github.com/nodejs/node/issues/21825

If anyone is interested in trying their hand at a fix, here's the relevant location in firebase-tools below. The code will probably need to be moved off of child_process.spawn and on to something else (or somehow make the child processes resistant to SIGINT before export.)

https://cs.opensource.google/firebase-sdk/firebase-tools/+/master:src/emulator/downloadableEmulators.ts;drc=f200dcb4865763a05c0426f4c3ec9640c9c4ff7f;l=369

A proper fix ideally would shut down the entire suite on SIGINT in the main window and needs to preserve export behavior.

christhompsongoogle avatar Mar 31 '23 19:03 christhompsongoogle