Firebase Functions stopped Working and Can't deploy again - firebase

Firebase Cloud functions giving an error called.
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
When I try to re-deploy, it gives following error.
Error setting up the execution environment for your function. Please try again after a few minutes.
What could be the reason? Is it following issue?
Sates: https://status.firebase.google.com/incident/Functions/18018

Yes there is an issue with Cloud Functions, as you can see from the link above
Investigating an issue with Functions
Incident began at 2018-03-09 03:30 (all times are US/Pacific).
Last update is this:
Mar 09, 2018 04:45
We are still investigating the issue with Cloud Functions execution. We will provide another status update as soon as possible.
https://status.firebase.google.com/incident/Functions/18018
After the issue is done, you will be able to deploy your functions again using the below:
firebase deploy --only functions
Edit:
I just deployed some functions and it is working now, just takes a bit of time.

I had the same issue and it was fixed after updating firebase-tools. I saw following on my console
Update available 7.0.0 → 7.8.1
Run npm i -g firebase-tools to update
Then i just changed node version and updated firebase tools
nvm use 11
npm upgrade firebase-tools -g
Sometimes switching environment will also help
firebase use dev
Sometimes when some node modules are not installed , the error you get will be like below
Deployment error.
Error setting up the execution environment for your function. Please try deploying again after a few minutes.
Make sure that all node modules are installed prior to deployment, I wasted almost 2 days and realised one node module was not installed .

I tried several different steps, including updating tools from firebase, using different node versions or dependencies on package.json. In the end, at firebase functions console, I cleared the log stack and tried to reach every deployment notification after executing firebase deploy. I found out one of my dependencies were moved from dependencies to devDependencies, which was causing
ERROR: (gcloud.beta.functions.deploy) OperationError: code=13, message=Error setting up the execution environment for your function. Please try again after a few minutes.
Solution:
Place back dependency on its place, moving from devDependencies into dependencies itself.
Update project dependencies with npm install
Re-deploy with firebase deploy

Related

CICD on GCP for Firebase Functions failing due to "replace /workspace/.runtimeconfig.json?" error

I have CICD for cloud functions as some of the functions require token (collection deletion), my pipeline takes care of that.
Since last release, the cloud build is failing to deploy functions as it's expecting some key press which can't be done during cloud build. The actual log error says the following:
"replace /workspace/.runtimeconfig.json? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL"
Locally I am able to run the Cloud Functions with Node 14, but on GCP I'm not able to find a fix for GCP Cloud Build.
**Note: **
I'm using latest packages as of today. firebase-tools package: 9.4.0
There are similar questions for deploying functions locally but none of them work for me as it's during Cloud Build. I'm using the guide here: https://cloud.google.com/build/docs/deploying-builds/deploy-firebase
https://github.com/firebase/firebase-tools/issues/3120
Firebase Functions deploy requires keyboard input in GCP
Well the answers on other links mentioned above were correct indeed. What I didn't realize was that Docker image of node during build takes the latest automatically. Thus, now it was taking Node 15.xx version.
To fix this, just update Node version in the cloudbuild.yaml. For example following during npm install on GCP:
- name: node:14
entrypoint: npm
waitFor: ['-']
id: 'npm-install'
dir: 'functions'
args: ['install']

Firebase Deployment Error "Error: Functions did not deploy properly."

I have deployed Firebase functions in the past many times. For some reasons, recently (around 2-3 days) I am frequently getting error while deployment. I am using windows to release the code. When I tried with setting up the same project in my Linux system and Mac system the deployment works correctly. What may be the issue for the release from Windows environment.
The following is the issues getting while deployment.
! functions[payment(us-central1)]: Deployment error.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Functions deploy had errors with the following functions:
admin
cancellation
cost
createStripeCharge
customer
driver
driverLiveTracking
generalSettings
notification
order
payment
To try redeploying those functions, run:
firebase deploy --only "functions:admin,functions:cancellation,functions:cost,functions:createStripeCharge,functions:customer,functions:driver,functions:driverLiveTracking,functions:generalSettings,functions:notification,functions:order,functions:payment"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Following is the deployment command I am using for
"echo Deploying Functions && npm run lint && npm run build && firebase deploy --only functions"
Please share your knowledge over the issue.
Thanks.
I have resolved this issue. On building, I found that the node modules and lib functions are not replacing correctly with the new build. I have done a name changing previously and that are not reflecting in the new build.
Steps followed:
Removed node modules and lib files
Npm install
Npm run serve
And a new build is worked fine as well. I got the same issue using Jenkins build also. I just manually removed the same in server also.
You can find the issue by examining the actual logs. view them using this command
firebase functions:log
The specific issue will be visible there. I sometimes had error as simple as a missing packages in package.json

Deploy a SSR Nuxt 2 application on firebase

I have some troubles deploying a Nuxt 2.4 application on Firebase.
I tried these 2 tutorials but they seem outdated:
https://www.youtube.com/watch?v=ZYUWsjUxxUQ
https://github.com/davidroyer/nuxt2-ssr-firebase
With the first tutorial, I could make my app working on local (after few hours and with a lot of modifications for babel integration) but I never could serve or deploy it. I thought the tutorial was old and manipulations can't be exactly done like the guy did.
With the second tutorial, I cloned the repository to try to deploy the example. I had to change 2 things : install Node 8 instead of Node 10 and upgrading firebase-admin to the last version in prod/server dir. Here is what I got:
npm run setup is ok
npm run dev is ok and the project works fine
npm run build is ok
npm run serve fails.
First I got this error :
The Cloud Functions emulator requires the module "firebase-admin" to be version >7.0.0 so your version is too old. You can probably fix this by running "npm install firebase-admin#latest" in your functions directory.
Indeed, the version configured in package.json is the 5.13. I did the update from the prod/server dir, and I get the 8.0.0.
And then I got a different error about gRPC :
Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v57-darwin-x64-unknown
Found: [node-v64-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
I tried npm rebuild as mentionned, without success.
npm run deploy fails.
I get this trace:
i deploying functions, hosting
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing prod/server directory for uploading...
Error: Error parsing triggers: Cannot find module 'acorn'
Try running "npm install" in your functions directory before deploying.
Of course, I tried the npm install from prod/server dir, but nothing changed.
Is there somewhere i can find a tutorial that can help me deploy my SSR app to firebase ? Thanks in avdance !
EDIT 1 :
After a few modifications on my package.json
upgrading firebase-functions and express to the latest versions
downgrading firebase-admin to the 7.0.0 version
adding acorn
I can serve and deploy but I get a "504 gateway time-out" webpage when I call the URL....
Have you tried to run npm install grpc inside functions folder?

Can't install google cloud functions emulator

I am trying to update firebase to the lastest version and encountered an error. That pointed me to the functions-emulator having an issue:
$ npm install #google-cloud/functions-emulator
npm ERR! Unexpected end of JSON input while parsing near '..."retry-request":"^4.0'
This happens after the recent update on firebase. Am I doing something wrong or is this bug I should report?
Tried multiple solutions including a complete de-install of npm, node and even vsc. Updating npm, trying to install the cloud functions emulator specifically...always the same error in some dependency file.
Here's the error log
88 error Unexpected end of JSON input while parsing near '..."retry-request":"^4.0'
I was just looking to update firebase to the latest version. Now everything is broken :D
Any help is much appreciated.
Error occurred due to a corrupted file download (tried installing a firebase update on the train).
Solved with:
npm cache clean --force
Then re-installed package.

Setting up Firebase CLI to use Functions

I am trying to update my Firebase CLI installation, in order to use the cloud functions for my project. I followed the getting-started guide, however for some reason, the CLI cannot detect the updated version.
I initialized a project of mine that I have already created via the Firebase console. During the project initialization, Firebase CLI mentioned that my CLI version should be updated, however the complete procedure went smoothly.
Once the initialization completed, I run for the first time (to update the CLI):
npm install -g firebase-tools
Once the updated finished, the command line reported:
firebase-tools#3.18.6
But when I run
firebase init functions
I get:
Error: CLI is out of date (on 3.0.1 , need at least 3.0.5)
I don't understand why this is happening, since the update reported that version 3.18.6 got installed Any hints would be great!
For reference, you can see a snapshot of the command line here.
It looks like you may have multiple versions of node installed in different locations. First, uninstall all versions of node that you may have previously installed. Make sure running node on the command line doesn't execute anything. Then, reinstall everything. After you've installed the Firebase CLI again, check its version with firebase --version.

Resources