Skip to content

Improve emulator env-related error-handling (e.g. missing java) #3443

Closed

Description

@yuri-sergiichuk

[REQUIRED] Environment info

firebase-tools: 9.12.1

Platform: Ubuntu 20.04 (via WSL2)

[REQUIRED] Test case

Run firebase-tools without java being installed.

[REQUIRED] Steps to reproduce

Install firebase-tools, run firebase init and then smth like firebase emulators:start --only storage.

[REQUIRED] Expected behavior

firebase-tools complains about missing java.

[REQUIRED] Actual behavior

Smth like this is dumped into the debug log:

[debug] [2021-06-03T11:20:32.039Z] ----------------------------------------------------------------------
[debug] [2021-06-03T11:20:32.041Z] Command:       /home/<user>/.nvm/versions/node/v14.17.0/bin/node /home/<user>/.nvm/versions/node/v14.17.0/bin/firebase emulators:start
[debug] [2021-06-03T11:20:32.041Z] CLI Version:   9.12.1
[debug] [2021-06-03T11:20:32.041Z] Platform:      linux
[debug] [2021-06-03T11:20:32.041Z] Node Version:  v14.17.0
[debug] [2021-06-03T11:20:32.041Z] Time:          Thu Jun 03 2021 14:20:32 GMT+0300 (Eastern European Summer Time)
[debug] [2021-06-03T11:20:32.041Z] ----------------------------------------------------------------------
[debug]
[debug] [2021-06-03T11:20:32.045Z] > 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"]
[debug] [2021-06-03T11:20:32.046Z] > authorizing via signed-in user (<user>)
[info] i  emulators: Starting emulators: storage {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: storage"}}
[warn] ⚠  emulators: It seems that you are running multiple instances of the emulator suite for project <project>. This may result in unexpected behavior.
[debug] [2021-06-03T11:20:32.059Z] [hub] writing locator at /tmp/hub-<project>.json
[debug] [2021-06-03T11:20:32.083Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"storage"},"message":"Ignoring unsupported arg: port"}}
[debug] [2021-06-03T11:20:32.151Z] Error: spawn java ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
[error]
[error] Error: An unexpected error has occurred.

** Additional info

As soon as I install java the very same command works without a glitch.

Activity

  1. google-oss-bot commented on Jun 3, 2021

    @google-oss-bot
    Collaborator

    This issue does not seem to follow the issue template. Make sure you provide all the required information.

  2. added
    polish
    on Jun 3, 2021
  3. samtstern commented on Jun 3, 2021

    @samtstern
    Contributor

    Hmmm interesting I thought we handled this:

    emulator.instance.on("error", async (err: any) => {

        emulator.instance.on("error", async (err: any) => {
          if (err.path === "java" && err.code === "ENOENT") {
            await _fatal(
              emulator,
              `${description} has exited because java is not installed, you can install it from https://openjdk.java.net/install/`
            );
          } else {
            await _fatal(emulator, `${description} has exited: ${err}`);
          }
        });

    I wonder why that block isn't catching the error ... maybe this is Windows or WSL specific?

  4. samtstern commented on Jun 3, 2021

    @samtstern
    Contributor

    Ahhh I see this is storage specific. The Rules runtime (which is a .jar) does not start using the same logic.

  5. added and removed
    polish
    on Jun 3, 2021
  6. samtstern commented on Jun 3, 2021

    @samtstern
    Contributor

    @abeisgoat can you try to unify some of the logic so that the rules runtime benefits from the downloadableEmulators stuff?

  7. abeisgoat commented on Jun 9, 2021

    @abeisgoat
    Contributor

    so sadly we had to diverge and not reuse a lot of the downloadableEmulator logic because the storage emulator's relationship to it's java process is very different than a downloadableEmulator, when I looked before it seemed that it would take a major refactor to support both use-cases from a single class, but that logic definitely handles errors better, so I'll either break that out or just improve ours so it's not as weak

  8. added a commit that references this issue on Jun 9, 2021
    c05f2b5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions