Skip to content

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

Closed

Description

@markgoho

[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

Activity

  1. DKorosec commented on Jan 19, 2022

    @DKorosec

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

  2. blikblum commented on Apr 10, 2022

    @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.
    
  3. DKorosec commented on Apr 11, 2022

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

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

  4. Corchoneitor commented on Jul 25, 2022

    @Corchoneitor

    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.

  5. lisajian commented on Jul 25, 2022

    @lisajian
    Contributor

    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

  6. Psycarlo commented on Oct 26, 2022

    @Psycarlo

    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

  7. markgoho commented on Oct 26, 2022

    @markgoho
    Author

    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.

  8. ishowta commented on Nov 1, 2022

    @ishowta

    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

  9. Wadeck commented on Jan 1, 2023

    @Wadeck

    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.

  10. christhompsongoogle commented on Mar 31, 2023

    @christhompsongoogle
    Contributor

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

    nodejs/node#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.

  11. akettmann-id commented on Aug 23, 2024

    @akettmann-id

    Currently facing the same struggle here, we have Python code that uses Firebase. Unit tests need a firebase emulator, but if I send the main process a SIGINT, it dies immediately and leaves its child processes (the actual emulators) behind and running.

    Reproducible with the following:

    import subprocess
    import signal
    import shutil
    import time
    
    FIREBASE = shutil.which('firebase')
    
    # Process starts here
    proc = subprocess.Popen([FIREBASE, 'emulators:start'])
    time.sleep(30)
    proc.send_signal(signal.SIGINT)
    # Python checks the subprocess and updates the returncode
    proc.poll()
    assert proc.returncode == -2

    will leave any emulators you may have started up and running. I can't find any signal I can send the process to get it to shut down cleanly. Going to do something dumb with firebase emulators:exec running some Python code that will shut down once I ask it to instead. Making my entrypoint for ALL of my tests be the firebase emulator doesn't work for me.

  12. Psycarlo commented on Nov 4, 2026

    @Psycarlo

    After 5 years, we got a fix! Uh-hu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions