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

Firebase Emulator Suite UI unable to start

Open rosera opened this issue 3 years ago • 42 comments

Note: Before filing bugs in this repo, please ensure that this is a bug for the Emulator Suite UI. Emulator Suite and/or Firebase CLI bugs should be filed under the firebase-tools repo here: https://github.com/firebase/firebase-tools/issues/new/choose

Describe the bug A clear and concise description of what the bug is.

This issue on stackflow covers the error I am seeing when acccessing the Emulator UI https://stackoverflow.com/questions/75840698/i-cannot-run-firebase-emulators-on-fresh-install-getting-syntaxerror-unexpec

To Reproduce Steps to reproduce the behavior:

I am using a fresh install of Firebase tools on Mac.

firebase --version

11.25.1

MacOS

13.2.1 (22D68)

firebase emulators:start results in a UI error logged

/Users/r/.cache/firebase/emulators/ui-v1.11.4/server/server.js:569
        re"use strict";
          ^^^^^^^^^^^^

SyntaxError: Unexpected string
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1195:20)
    at Module._compile (node:internal/modules/cjs/loader:1239:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Node.js v19.8.1

Expected behavior Should be able to start the Firebase Emulator suite UI

Screenshots N/A

Desktop (please complete the following information):

  • OS: MacOS 13.2.1
  • Browser: ChromeOS
  • Version: 111.0.5563.110

Smartphone (please complete the following information):

N/A

Additional context New Flutter project added Authentication and Cloud Firestore emulator components. npm: 9.5.1 node: 19.8.1 openjdk version "11.0.18" 2023-01-17 OpenJDK Runtime Environment Homebrew (build 11.0.18+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.18+0, mixed mode)

rosera avatar Mar 25 '23 14:03 rosera

I downgraded my node to LTS v16.19.1 and flushed the cache. That did the trick - I can now start the emulator on my device.

brew install node@16

flush the cache

rm -rf ~/.cache/firebase

rosera avatar Mar 25 '23 16:03 rosera

Copy & Paste Solution:

brew install node@16
export PATH="/opt/homebrew/opt/node@16/bin:$PATH"
rm -rf ~/.cache/firebase
npm install -g firebase-tools
firebase emulators:start

pich4ya avatar Mar 26 '23 08:03 pich4ya

We have some additional reports of this happening, though I'm not able to reproduce it. If anyone has additional details to share please comment on this issue.

For example some questions to help us narrow this down: does this happen with a fresh install? Is it only with Node 19?

christhompsongoogle avatar Mar 31 '23 19:03 christhompsongoogle

Had another customer report that they encountered this on both node 18 and node 19 - unable to repro it myself though.

joehan avatar Mar 31 '23 20:03 joehan

In my case I had a fresh install on a MacOS and Linux hosts (relevant tech stack in the original post).

I didnt need to reinstall the tooling e.g. npm i -g firebase-tools. Downgrading the node version and removing the local cache did the trick for my situation.

Using the following Dockerfile I am able to replicate the original error message:

FROM debian:stable-slim

# Install updates
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y curl gcc g++ make default-jre
RUN curl -sL https://deb.nodesource.com/setup_19.x | bash -
RUN apt-get install -y nodejs

RUN npm install -g firebase-tools
RUN useradd -ms /bin/bash firebase-dev

USER firebase-dev
WORKDIR /home/firebase-dev

Build the image

docker build -t firebase-dev .

Run the container interactively with access to the host network

docker run -it --net=host firebase-dev /bin/bash

Then

  • firebase login
  • firebase init
  • Add Authentication Emulator and use default port values
  • firebase emulators:start

At this point the following error message is shown:

firebase-dev@penguin:~$ firebase emulators:start
i  emulators: Starting emulators: auth
i  ui: downloading ui-v1.11.4.zip...
Progress: ========================================================================================================================================================================================================================> (100% of 4MB)
i  ui: Emulator UI logging to ui-debug.log
⚠  ui: Fatal error occurred: 
   Emulator UI has exited with code: 1, 
   stopping all running emulators
i  ui: Stopping Emulator UI
⚠  ui: Error stopping Emulator UI
i  auth: Stopping Authentication Emulator
i  hub: Stopping emulator hub
i  logging: Stopping Logging Emulator
firebase-dev@penguin:~$ cat ui-debug.log
/home/firebase-dev/.cache/firebase/emulators/ui-v1.11.4/server/server.js:569
        re"use strict";
          ^^^^^^^^^^^^

SyntaxError: Unexpected string
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1195:20)
    at Module._compile (node:internal/modules/cjs/loader:1239:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Node.js v19.8.1

rosera avatar Apr 01 '23 10:04 rosera

having same issue on mac

/Users/mac/.cache/firebase/emulators/ui-v1.11.4/server/server.js:569
        re"use strict";
          ^^^^^^^^^^^^

SyntaxError: Unexpected string
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1195:20)
    at Module._compile (node:internal/modules/cjs/loader:1239:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Node.js v19.8.1

Miamoto-Musashi avatar Apr 03 '23 12:04 Miamoto-Musashi

Downgrading to Node 18 and clearing the cache as decribed above (copied here for signal boost) seems to resolve the issue. Node 19 is an experimental release. I'm still not clear why the cache clear is required though. There's a new release of the UI coming out this week that may resolve it.

nvm install --lts
rm -rf ~/.cache/firebase
npm install -g firebase-tools
firebase emulators:start

christhompsongoogle avatar Apr 04 '23 20:04 christhompsongoogle

Faced this issue using Node 19, downgrading to 18 worked for me.

Zaffer avatar Apr 10 '23 14:04 Zaffer

I get the exact same error on my Mac. Even after following the instructions by @christhompsongoogle. Node 19 or 18, and deleting cache, produces the same error.

wyvx avatar Apr 13 '23 11:04 wyvx

@wyvx On my Mac environment I needed to ensure it matched both Node.js and Java requirements.

npm: 9.5.1
node: LTS Version
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment Homebrew (build 11.0.18+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.18+0, mixed mode)

rosera avatar Apr 13 '23 12:04 rosera

I had an issue using the solutions above, due to multiple node versions installed with Homebrew.

I solved it with these steps:

  1. brew install node@18
  2. brew unlink node
  3. brew link node@18
  4. rm -rf ~/.cache/firebase
  5. firebase emulators:start --import persisted_data --export-on-exit

CTxD avatar Apr 15 '23 12:04 CTxD

@CTxD you can also go for version @18 and works fine

Miamoto-Musashi avatar Apr 15 '23 13:04 Miamoto-Musashi

Only thing that worked for me was to go to ~/.cache/firebase/emulators/ui-v1.11.5 and manually unzip ui-v1.11.5.zip there.

tu4mo avatar Apr 15 '23 18:04 tu4mo

Copy & Paste Solution:

brew install node@16
export PATH="/opt/homebrew/opt/node@16/bin:$PATH"
rm -rf ~/.cache/firebase
npm install -g firebase-tools
firebase emulators:start

Worked for me. Very annoying problem firebase team :(

donhmorris avatar Apr 15 '23 23:04 donhmorris

Running NodeJS 18 and firebase-tools 11.27.0 here. Tried manually clearing the cache, unfortunately that didn't help. Unzipping the cache myself did work though, for some reason.

Looking at the difference between the 2 server.js files, there's, what looks to me, like some transpilation/bundling that's happening differently.

danshilm avatar Apr 16 '23 11:04 danshilm

@wyvx On my Mac environment I needed to ensure it matched both Node.js and Java requirements.

npm: 9.5.1
node: LTS Version
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment Homebrew (build 11.0.18+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.18+0, mixed mode)

From the initial issue, there are two issues at play.

  1. Not using Node.js LTS version.
  2. Not using the Java 11 version.

Correcting the development environment to support the above, should resolve the issue. If you are still facing issues, you can independently test using the container manifest and adjust to the values as required:

FROM debian:stable-slim

# Install updates
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y curl gcc g++ make default-jre
RUN curl -sL https://deb.nodesource.com/setup_19.x | bash -
RUN apt-get install -y nodejs

RUN npm install -g firebase-tools
RUN useradd -ms /bin/bash firebase-dev

USER firebase-dev
WORKDIR /home/firebase-dev

In the above example, changing the nodesource from 19 to an LTS version will result in a working environment.

rosera avatar Apr 17 '23 10:04 rosera

I am running the emulators inside Docker on node:18-alpine version and it's failing with the same error.

FROM node:18-alpine

RUN apk add openjdk11 curl

RUN npm install -g firebase-tools

RUN firebase setup:emulators:database
RUN firebase setup:emulators:ui


RUN mkdir -p /firebase

EXPOSE 4400
EXPOSE 4500
EXPOSE 5001
EXPOSE 5002
EXPOSE 5003
EXPOSE 5010
EXPOSE 5015
EXPOSE 5016
EXPOSE 5017
EXPOSE 9099
EXPOSE 9000


WORKDIR /firebase

ENTRYPOINT firebase --project=<PROJECT_ID> emulators:start --only database,auth,ui,hosting

Can you guys check the recent updates to the bundling logic of server.ts? Last commit I found related to this was: https://github.com/firebase/firebase-tools-ui/commit/dacf96e12d6fbe23cc921feba625f08a259d5a9c but it's quite a long time ago. I feel like I was able to run this container on Thursday (13/04/2023), now (17/04/2023) I can't 😞

Durisvk avatar Apr 17 '23 16:04 Durisvk

Having the same issue in docker after the newest update. Docker Image: node:18-alpine Java Version: openjdk version "11.0.18" 2023-01-17 Node Version: 18.16.0 MacOS Version: 13.3.1

Already on node18 and openjdk11. Already tried flushing the cache.

Here's what the logs look like just before the error occurs:

✔  firestore: Firestore Emulator UI websocket is running on 9150. {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator UI websocket is running on 9150."}}
i  ui: downloading ui-v1.11.4.zip... {"metadata":{"emulator":{"name":"ui"},"message":"downloading ui-v1.11.4.zip..."}}
[2023-04-17T23:31:22.629Z] >>> [apiv2][query] GET https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.11.4.zip 
[2023-04-17T23:31:22.723Z] <<< [apiv2][status] GET https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.11.4.zip 200
[2023-04-17T23:31:22.724Z] <<< [apiv2][body] GET https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.11.4.zip [stream]
[2023-04-17T23:31:26.140Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-04-17T23:31:26.141Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}

DevDaveFrame avatar Apr 17 '23 23:04 DevDaveFrame

For those who is struggling with this issue, please read my comment here: https://github.com/firebase/firebase-tools/issues/5614#issuecomment-1508515106 to understand what's going on.

How to fix: Essentially you need to make sure you installing your emulators using node 18.15.0 or lower. If you have your emulators installed using higher version of node: remove it from cache folder (usually ~/.cache/firebase).

Unfortunately it's not very easy to install a specific node version in your docker container. In the comment I shared my dockerfile to provide an idea of how to install it with nvm.

CC @DevDaveFrame @Durisvk

Hi @rosera, I believe Java version is not important, replying to:

From the initial issue, there are two issues at play.

  1. Not using Node.js LTS version.
  2. Not using the Java 11 version.

PS: One more comment about LTS version as a solution: No, it won't work and if this does work it's sheer luck, because what really happens is:

  • You are using cached emulators downloaded by good version of node (v18.15.x/v19.7.x or lower) .
  • The repository that you've downloaded your LTS node from is still giving you v18.15.0 and not v18.16.0 which is the latest one as of today and running on which firebase-tools struggle to unzip downloaded PubSub & UI emulators.

CC @christhompsongoogle

iSuslov avatar Apr 18 '23 01:04 iSuslov

v18.16.0 LTS https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#18.16.0

This is a new release (12th April I believe?) - if you have an issue with a specific version you can test using the dockerfile to verify the environment.

FROM debian:stable-slim

# Install updates
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y curl gcc g++ make default-jre
RUN curl -sL https://deb.nodesource.com/setup_19.x | bash -
RUN apt-get install -y nodejs

RUN npm install -g firebase-tools
RUN useradd -ms /bin/bash firebase-dev

USER firebase-dev
WORKDIR /home/firebase-dev

rosera avatar Apr 18 '23 06:04 rosera

Got the same problem with node 18.16 (ui-emulator v1.11.5). Downgrading node to 18.15 and removing ~/.cache/firebase solved the issue.

edupsousa avatar Apr 19 '23 13:04 edupsousa

i'm facing the same issue and even after confirming my node, npm, and openjdk versions are as listed by @rosera , I can't resolve the error. Tried clearing and removing my cache multiple times.

hiftikha avatar Apr 22 '23 08:04 hiftikha

Looks like it finally worked after removing cache one last time, again!

hiftikha avatar Apr 22 '23 08:04 hiftikha

If you're using VS Code devcontainers with feature ghcr.io/devcontainers/features/node, the good news is nvm is set up and works nicely. nvm install 18.15 && nvm use 18.15 worked around this issue for me.

jasonprado avatar Apr 27 '23 17:04 jasonprado

I tried downgrading node version, Java version, etc. Not much seemed to work. Unzipped ui-v1.11.5.zip manually in ~/.cache/firebase, and it's working now. My env is now OpenJDK 11 and Node 18.15.0 .

callumbirks avatar Apr 30 '23 18:04 callumbirks

I tried downgrading node version, Java version, etc. Not much seemed to work. Unzipped ui-v1.11.5.zip manually in ~/.cache/firebase, and it's working now. My env is now OpenJDK 11 and Node 18.15.0 .

I had my doubts, but this worked! Thanks @callumbirks :)

jkang027 avatar May 01 '23 18:05 jkang027

can confirm that pub/sub breaks the emulator on Latest LTS Version: 18.16.0

davie-robertson avatar May 01 '23 18:05 davie-robertson

I am also running into this on my Mac using Docker. Here is the dockerfile for the fail scenario. Previously worked with older version of firebase-tools of 11.12.0.

FROM node:18-alpine

EXPOSE 4000
EXPOSE 5000
EXPOSE 5001
EXPOSE 8080
EXPOSE 8085
EXPOSE 9000
EXPOSE 9005
EXPOSE 9099
EXPOSE 9199
EXPOSE 9991
EXPOSE 9119

ENV HOME=/home/node

RUN apk --no-cache add openjdk11-jre bash && \
    yarn global add [email protected] && \
    yarn cache clean && \
    firebase setup:emulators:database && \
    firebase setup:emulators:firestore && \
    firebase setup:emulators:pubsub && \
    firebase setup:emulators:storage && \
    firebase -V && \
    java -version && \
    chown -R node:node $HOME

ADD ./firebase-emulator.json /home/node/firebase.json

USER node
VOLUME $HOME/.cache
WORKDIR $HOME
CMD ["sh"]

mattdknapp avatar May 02 '23 16:05 mattdknapp

Thank you all for the reports - this is caused by a break in our unzipper library dependency. We have a fix pending from Durisvk and are trying to get that in ASAP to resolve this issue.

Workaround:

  • Downgrade your node.js version to 18.5 or earlier
  • Remove your .cache/firebase to ensure the emulators are freshly downloaded (and unzipped).

christhompsongoogle avatar May 02 '23 19:05 christhompsongoogle

The fix for this was released in v11.30.0, see here: https://github.com/firebase/firebase-tools/releases/tag/v11.30.0

Please upgrade past this to resolve the issue and let me know if you're still encountering any issues.

christhompsongoogle avatar May 08 '23 18:05 christhompsongoogle