firebase-tools: firebase-tools v11.3.0 deploy fails for gen2 Cloud Functions

[REQUIRED] Environment info

firebase-tools: 11.3.0

Platform: macOS

[REQUIRED] Test case

A firebase project with gen2 cloud functions and local version of firebase-tools === 11.3.0. Firebase deploy fails.

[REQUIRED] Steps to reproduce

  1. Install the latest version of Firebase CLI: npm install -g firebase-tools@11.3.0
  2. Create a firebase project: firebase init
  3. Add a gen2 cloud function
  4. Run firebase deploy

[REQUIRED] Expected behavior

Firebase deploy success.

[REQUIRED] Actual behavior

Deploy fails with following error: Error: Failed to fetch Run service undefined.

If we run firebase deploy --debug, we get:

[2022-12-14T15:01:42.800Z] FirebaseError: Failed to make request: Cannot read properties of undefined (reading 'startsWith')
    at Client.request (/Users/user/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/apiv2.js:111:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.getService (/Users/user/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/gcp/run.js:17:26)
    at async Promise.all (index 0)
    at async loadExistingBackend (/Users/user/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/functions/backend.js:197:28)
    at async Object.existingBackend (/Users/user/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/functions/backend.js:173:9)
    at async prepare (/Users/user/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/functions/prepare.js:110:115)
    at async chain (/Users/user/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/index.js:33:9)
    at async deploy (/Users/user/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/index.js:68:5)

Temporary Fix:

In order to fix the error, I had to remove Firebase tools (v 11.3.0) from my system and install Firebase tools v11.18.0. Deploy succeeds.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 19 (3 by maintainers)

Most upvoted comments

For me in linux (ubuntu), firebase -V and firebase tools --version showed something like v11.7 even after an update npm -g i firebase-tools@latest, but npm -g list showed version 11.18.0

I tried to remove firebase-tools with npm -g remove firebase-tools, but even after that the firebase command was still available and still showed v11.7

I used which firebase to figure out where the firebase command was located, and removed it manually rm /usr/bin/firebase.

And then reinstalled firebase-tools with npm -g i firebase-tools@latest. And after that I was able to do a deploy.

I’m on mac, I needed to do a similar thing. I’m using nvm, and needed to run which firebase twice and delete with rm <location> in both places before running npm -g i firebase-tools@latest, but that fixed my issue.

facing the same issue nothing works for me from the mentioned suggestion

Try running “$ firebase tools --version” FROM the project directory. What version of firebase-tools are you using?

Basically ensure that it is 11.18.0

For me in linux (ubuntu), firebase -V and firebase tools --version showed something like v11.7 even after an update npm -g i firebase-tools@latest, but npm -g list showed version 11.18.0

I tried to remove firebase-tools with npm -g remove firebase-tools, but even after that the firebase command was still available and still showed v11.7

I used which firebase to figure out where the firebase command was located, and removed it manually rm /usr/bin/firebase.

And then reinstalled firebase-tools with npm -g i firebase-tools@latest. And after that I was able to do a deploy.

@colerogers when we update firebase-tools then we are also forced to update firebase-admin and firebase-functions. And this is also giving us another ERROR.

i  functions: Watching
"C:\....\functions\dist" for Cloud Functions...
The system cannot find the path specified.

Error: An unexpected error has occurred.

After some digging, we pushed a change back in September ( #5001 ) that allowed the firebase-tools CLI to handle an upstream change from the Google Cloud Functions API. This was released in version 11.9.0 and it looks like the GCF team recently rolled out the change on their end. That’s why you are seeing this error if you have an older firebase-tools version. The best course of action is to upgrade your tools version to be at least 11.9.0 but preferably the latest (which looks like most of you already have).

Apologies for the time spent trying to debug this issue, we rarely have upstream changes that break our tooling like this.

@ojetokun it works now thanks