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

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

Closed
yuri-sergiichuk opened this issue Jun 3, 2021 · 5 comments
Closed

Comments

@yuri-sergiichuk
Copy link

yuri-sergiichuk commented Jun 3, 2021

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

@google-oss-bot
Copy link
Contributor

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

@samtstern samtstern added the polish Small feature requests label Jun 3, 2021
@samtstern
Copy link
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?

@samtstern
Copy link
Contributor

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

@samtstern samtstern added emulators: storage type: bug and removed polish Small feature requests labels Jun 3, 2021
@samtstern
Copy link
Contributor

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

@abeisgoat
Copy link
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

abeisgoat added a commit that referenced this issue Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants