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

Pub/Sub Emulator has exited with code: 1 #5614

Closed
Ruisi-Lu opened this issue Mar 20, 2023 · 15 comments
Closed

Pub/Sub Emulator has exited with code: 1 #5614

Ruisi-Lu opened this issue Mar 20, 2023 · 15 comments
Assignees
Labels

Comments

@Ruisi-Lu
Copy link

[REQUIRED] Environment info

firebase-tools: 11.24.1
Node.js: v16.19.1
Java: OpenJDK 11.0.18

Platform: macOS13.2.1 M1

[REQUIRED] Test case

Run firebase emulators:start --only pubsub

[REQUIRED] Actual behavior

i  emulators: Starting emulators: pubsub
i  pubsub: Pub/Sub Emulator logging to pubsub-debug.log
⚠  pubsub: Fatal error occurred: 
   Pub/Sub Emulator has exited with code: 1, 
   stopping all running emulators
i  pubsub: Stopping Pub/Sub Emulator
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
⚠  pubsub: Error stopping Pub/Sub Emulator
i  hub: Stopping emulator hub
// pubsub-debug.log
Error: Invalid or corrupt jarfile /Users/ruisi/.cache/firebase/emulators/pubsub-emulator-0.7.1/pubsub-emulator/lib/cloud-pubsub-emulator-0.7.1.jar

I have tried to manually delete cloud-pubsub-emulator-0.7.1.jar, and use firebase setup:emulators:pubsub to reinstall.

@google-oss-bot
Copy link
Contributor

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

@christhompsongoogle
Copy link
Contributor

christhompsongoogle commented Mar 21, 2023

Thanks for the report. We're not able to reproduce this bug on our end just yet.

Question: I see you're running JDK11 - if you upgrade to the latest version JDK 19 or 20, does that resolve the issue?

https://openjdk.org/projects/jdk/

Other ideas to help us identify the issue:
Ensure you have a project selected via firebase use
If you're up for it, try the emulator via the gcloud CLI, instructions here: https://cloud.google.com/pubsub/docs/emulator

@christhompsongoogle christhompsongoogle added the Needs: Author Feedback Issues awaiting author feedback label Mar 21, 2023
@Ruisi-Lu
Copy link
Author

Thanks for the report. We're not able to reproduce this bug on our end just yet.

Question: I see you're running JDK11 - if you upgrade to the latest version JDK 19 or 20, does that resolve the issue?

https://openjdk.org/projects/jdk/

Other ideas to help us identify the issue: Ensure you have a project selected via firebase use If you're up for it, try the emulator via the gcloud CLI, instructions here: https://cloud.google.com/pubsub/docs/emulator

I was using Node19.8.1 and openjdk19.0.2 at the time of the problem, after I clean and reinstalled Node16 and jdk11 the problem still exists.

I can run pubsub emulator using gcloud CLI by gcloud beta emulators pubsub start .

  • Google Cloud CLI version: 423.0.0
  • Cloud Pub/Sub Emulator version: 0.8.1

@google-oss-bot google-oss-bot added Needs: Attention and removed Needs: Author Feedback Issues awaiting author feedback labels Mar 22, 2023
@christhompsongoogle
Copy link
Contributor

Thanks Ruisi-Lu,

If you run firebase emulators:start --only pubsub with the --debug flag, does it add any additional details of interest?

@Ruisi-Lu
Copy link
Author

Thanks Ruisi-Lu,

If you run firebase emulators:start --only pubsub with the --debug flag, does it add any additional details of interest?

Thanks for your help.
After I run pubsub emulator using cloud CLI, my firebase CLI can run pubsub emulator.
I try running gcloud components remove pubsub, and firebase CLI pubsub is also normal.
I can't able to reproduce the bug for now, and I don't understand where have problem.

@austinn
Copy link

austinn commented Mar 27, 2023

Possible related issue: firebase/firebase-tools-ui#933

As soon as I downgraded to Node 16, it started working again

@joehan joehan added Needs: Author Feedback Issues awaiting author feedback and removed Needs: Attention labels Mar 28, 2023
@nugentmichael1
Copy link

I had this issue until I downgraded Node from latest (19.x.x) to LTS (18.15.0).

@christhompsongoogle
Copy link
Contributor

Thanks for the input everyone, we've been seeing a few Node 19 errors so downgrading to 18 should be a first step. If that doesn't resolve the issue please file an issue or post in this thread.

@tamerxkilinc
Copy link

Had the same issue today. The following instructions worked for me on macOS:

  1. Delete the downloaded jar file. You can find the directory when you start the emulators with the --debug flag.
  2. Make sure you use NodeJS 16 or 18
  3. Make sure you use Java 17 or 19
  4. Run the following command: firebase setup:emulators:pubsub. This will download the jar file.
  5. Try running the pubsub emulator again: firebase emulators:start --only pubsub

@iSuslov
Copy link

iSuslov commented Apr 14, 2023

😫 I've found the real issue.

To be clear, I'm talking about this error:

Error: Invalid or corrupt jarfile ...

  • It's not your Java
  • It's not your Docker settings (if you run one)
  • Affects any version of firebase-tools

What happens?
This issue occurs if you download & set up emulators using node v18.16+ or v19.8+. It works fine if you have emulators installed by other versions of node(I checked only v18.x.x & v19.x.x) even if you upgrade node version afterwards.
Since it only happens to pubsub & UI emulators (only those two have to be unzipped after downloading), I suspect that firebase-tools struggle to correctly unpack downloaded archives. firebase-tools have unzipper dependency, hence this may be related:
async iteration example no longer works in Node 18x, 19x
stream.pipeline [ERR_STREAM_PREMATURE_CLOSE]: Premature close

@christhompsongoogle & firebase team, please take a look at the changelogs for the node versions mentioned above to nail down the exact issue:
v19.8.0 changelog
v18.16.0 changelog


For those who is out of luck today and have their docker containers rebuilt and perhaps uses ubuntu as a base image to replicate cloud functions environment, me sharing my dockerfile config to use with a specific node version:

# Trying to replicate the exact cloud functions execution environment
# See https://cloud.google.com/functions/docs/concepts/execution-environment
ARG UBUNTU_VERSION=22.04
ARG NODE_VERSION=18.15.0
ARG JAVA_VERSION=18

FROM ubuntu:$UBUNTU_VERSION as emulators
ARG NODE_VERSION
ARG JAVA_VERSION

RUN apt-get update

ENV HOME=/home/node
ENV NVM_DIR=/usr/local/nvm
ENV NODE_PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin
ENV PATH=$NODE_PATH:$PATH

# We can install system packages that are available on cloud functions VMs
# Full list of pre-installed packages: https://cloud.google.com/functions/docs/reference/system-packages
RUN apt-get install -y \
    curl \
    openjdk-${JAVA_VERSION}-jre-headless # java is not preinstalled on cloud functions, but is needed to run emulators

# Install nvm, Node
RUN mkdir $NVM_DIR && \
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash && \
    bash $NVM_DIR/nvm.sh ${NODE_VERSION}

# Install firebase-tools and emulators \
RUN npm i -g firebase-tools && \
    firebase setup:emulators:database && \
    firebase setup:emulators:firestore && \
    firebase setup:emulators:pubsub && \
    firebase setup:emulators:storage && \
    firebase setup:emulators:ui

# Preserve firebase emulators cache
VOLUME $HOME/.cache

# Create a user 'node' make him an owner of $HOME
RUN groupadd --gid 1000 node && \
    useradd --uid 1000 --gid node --shell /bin/bash --create-home node && \
    chown -R node:node $HOME

WORKDIR $HOME
USER node
EXPOSE 4000
EXPOSE 5002
EXPOSE 5001
EXPOSE 8080
EXPOSE 8085
EXPOSE 9000
EXPOSE 9005
EXPOSE 9099
EXPOSE 9199
EXPOSE 9299
CMD ["sh"]

@vishna
Copy link

vishna commented Apr 14, 2023

This started happening to me today (only on Bitrise CI tho). I removed pubsub from firebase.json (since I didn't need it in my project anyway) and that "fixed" it.

Looks like @iSuslov might be right about something wrong with the unzipper

Error: Invalid or corrupt jarfile /Users/vagrant/.cache/firebase/emulators/pubsub-emulator-0.7.1/pubsub-emulator/lib/cloud-pubsub-emulator-0.7.1.jar

@nicobuch-southpole
Copy link

On my experience this issue was caused because of trying to run the Pub/Sub emulator with a non LTS version of Node. Once you downgrade Node, you also need to remove the entire .cache directory that it is pointed out so it can be regenerated with the new version.
Hope it helps!

@eastlondoner
Copy link

eastlondoner commented Apr 20, 2023

This reproduces the issue for us

FROM openjdk:20-slim

# Firebase emulator support in node versions is tricky
RUN apt-get update -y \
  && apt-get install -y curl \
  && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
  && apt-get update -y \
  && apt-get install -y nodejs \
  && apt purge curl -y \
  && apt clean -y \
  && apt autoremove -y \
  && rm -rf /var/lib/apt/lists/* 

RUN npm install -g firebase-tools@11.28.0

COPY entrypoint /firebase/entrypoint
WORKDIR /firebase

ENV GCLOUD_PROJECT="demo-firebase-emulator"

# Run a no-op command to download the firebase jar files (and store them in the docker image)
RUN firebase emulators:exec --only pubsub --project "${GCLOUD_PROJECT}" "exit 0"

ENTRYPOINT ["/firebase/entrypoint"]

switching the node install from lts.x to node 16.x fixes it for us

@jb-thery
Copy link

jb-thery commented Apr 23, 2023

I have this error with :

openjdk 20 2023-03-21
OpenJDK Runtime Environment Homebrew (build 20)
OpenJDK 64-Bit Server VM Homebrew (build 20, mixed mode, sharing)
node v18.16.0
Invalid or corrupt jarfile /Users/jbty/.cache/firebase/emulators/pubsub-emulator-0.7.1/pubsub-emulator/lib/cloud-pubsub-emulator-0.7.1.jar\n"}}
⚠  pubsub: Fatal error occurred: 
[2023-04-23T16:32:14.935Z] > 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"]
[2023-04-23T16:32:14.936Z] > authorizing via signed-in user (xxxx.xxx@xxxxx.xxxx)
i  emulators: Starting emulators: pubsub {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: pubsub"}}
[2023-04-23T16:32:15.161Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-04-23T16:32:15.162Z] [pubsub] Pub/Sub Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-04-23T16:32:15.162Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"pubsub":[{"address":"127.0.0.1","family":"IPv4","port":8085}]},"metadata":{"message":"assigned listening specs for emulators"}}
[2023-04-23T16:32:15.165Z] [hub] writing locator at /var/folders/7n/f_k_gzy90xjdd5l584mkc9z00000gn/T/hub-workoutgen-staging.json
[2023-04-23T16:32:15.168Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"pubsub"},"message":"Ignoring unsupported arg: projectId"}}
[2023-04-23T16:32:15.168Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"pubsub"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-04-23T16:32:15.168Z] Starting Pub/Sub Emulator with command {"binary":"/Users/jbty/.cache/firebase/emulators/pubsub-emulator-0.7.1/pubsub-emulator/bin/cloud-pubsub-emulator","args":["--host=127.0.0.1","--port=8085"],"optionalArgs":["port","host"],"joinArgs":true} {"metadata":{"emulator":{"name":"pubsub"},"message":"Starting Pub/Sub Emulator with command {\"binary\":\"/Users/jbty/.cache/firebase/emulators/pubsub-emulator-0.7.1/pubsub-emulator/bin/cloud-pubsub-emulator\",\"args\":[\"--host=127.0.0.1\",\"--port=8085\"],\"optionalArgs\":[\"port\",\"host\"],\"joinArgs\":true}"}}
i  pubsub: Pub/Sub Emulator logging to pubsub-debug.log {"metadata":{"emulator":{"name":"pubsub"},"message":"Pub/Sub Emulator logging to \u001b[1mpubsub-debug.log\u001b[22m"}}
[2023-04-23T16:32:15.336Z] Error: Invalid or corrupt jarfile /Users/jbty/.cache/firebase/emulators/pubsub-emulator-0.7.1/pubsub-emulator/lib/cloud-pubsub-emulator-0.7.1.jar
 {"metadata":{"emulator":{"name":"pubsub"},"message":"Error: Invalid or corrupt jarfile /Users/jbty/.cache/firebase/emulators/pubsub-emulator-0.7.1/pubsub-emulator/lib/cloud-pubsub-emulator-0.7.1.jar\n"}}
⚠  pubsub: Fatal error occurred: 
   Pub/Sub Emulator has exited with code: 1, 
   stopping all running emulators {"metadata":{"emulator":{"name":"pubsub"},"message":"Fatal error occurred: \n   Pub/Sub Emulator has exited with code: 1, \n   stopping all running emulators"}}
i  pubsub: Stopping Pub/Sub Emulator {"metadata":{"emulator":{"name":"pubsub"},"message":"Stopping Pub/Sub Emulator"}}
[2023-04-23T16:32:19.339Z] Pub/Sub Emulator: Unable to terminate process (PID=14918) {"metadata":{"emulator":{"name":"pubsub"},"message":"Pub/Sub Emulator: Unable to terminate process (PID=14918)"}}
[2023-04-23T16:32:19.340Z] [pubsub] {"name":"FirebaseError","children":[],"exit":1,"message":"pubsub: Pub/Sub Emulator: Unable to terminate process (PID=14918)","status":500}
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
⚠  pubsub: Error stopping Pub/Sub Emulator {"metadata":{"emulator":{"name":"pubsub"},"message":"Error stopping Pub/Sub Emulator"}}
i  hub: Stopping emulator hub {"metadata":{"emulator":{"name":"hub"},"message":"Stopping emulator hub"}}

@Rowanto
Copy link

Rowanto commented Apr 24, 2023

maybe it's not that obvious, but as mentioned in #5614 (comment)

you can just downgrade to node 18.15. so if you use a node:18 for your image, you can just pin the version to node:18.15 and it should fix the issue temporarily.

@joehan joehan closed this as completed in 19a8384 May 2, 2023
ProfHercules pushed a commit to ProfHercules/firebase-tools that referenced this issue May 5, 2023
…#5714)

* Replace dependency on broken node-unzipper with native zlib

Fixes:
firebase#5614
firebase#5677
firebase/firebase-tools-ui#939
firebase/firebase-tools-ui#940

* remove unused broken.zip fixture

* add changelog record

* fix timing out test

* fix use operating system file delimiter

* addressing code review comments from @joehan

* better support for Windows path separators

TODO: remove console logs after @christhompsongoogle tries it out.

* addressing code review comments from @joehan

* Add support for zip files that use signed data descriptors instead of a full entry header

* Formats, fixes uneeded async/await

* Remove unnecessary handling for empty files

* Remove console.log

---------

Co-authored-by: joehan <joehanley@google.com>
tonyjhuang pushed a commit that referenced this issue May 22, 2023
* Replace dependency on broken node-unzipper with native zlib

Fixes:
#5614
#5677
firebase/firebase-tools-ui#939
firebase/firebase-tools-ui#940

* remove unused broken.zip fixture

* add changelog record

* fix timing out test

* fix use operating system file delimiter

* addressing code review comments from @joehan

* better support for Windows path separators

TODO: remove console logs after @christhompsongoogle tries it out.

* addressing code review comments from @joehan

* Add support for zip files that use signed data descriptors instead of a full entry header

* Formats, fixes uneeded async/await

* Remove unnecessary handling for empty files

* Remove console.log

---------

Co-authored-by: joehan <joehanley@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests