Firebase Cloud Functions Deploy Error - Quota Exceeded - firebase

I'm trying to deploy firebase cloud functions, but I'm getting the following:
functions: got "Quota Exceeded" error while trying to update projects/...
and another error:
functions: Unhandled error cleaning up build images. This could result in a small monthly bill if not corrected. You can attempt to delete these images by redeploying or you can delete them manually at [URL].
Which quota is being exceeded? And how do I increase that quota?
Thank you.

Same error for me , but handled by deploying target functions by firebase deploy --only functions:orgWalletTransCreate

As per this article try to delete all your functions and re upload them again.
I do not like this solution as it not something you want to do in a production environment, but it's the only way I found to upload changes.
Besides, I only encounter this issue in my dev project where I upload frequently several times a day on a busy day.

Related

Deploy to Firebase Hosting on merge results in error

I have started to host a React app on Firebase including Github workflows (firebase-hosting-merge.yml and firebase-hosting-pull-request.yml).
While I could solve the the error in firebase-hosting-pull-request.yml using Deploy to Firebase Hosting on PR faild in github actions, I cannot solve the error ("Error: Process completed with exit code 1.") in firebase-hosting-merge.yml.
Does anybody know how to solve that?
How would I remove the workflows (as I don't really need them)? (Can I simply remove the folder ".github/workflows"?)
Code:

Can't deploy Cloud Functions because of "Unhandled error cleaning up build images"

I've deployed hundreds of function and this is the first time I encounter this issue. Simply, it stops deploying function process, saying:
Unhandled error cleaning up build images. This could result in a small monthly bill if not corrected. You can attempt to delete these images by redeploying or you can delete them manually at https://console.cloud.google.com/gcr/images/[project-name]/us/gcf
The way I deploy is through Firebase CLI command: firebase deploy --only functions:nameOfFunction
Question is what are those images I have to delete? Why? How can I solve it?
Cloud Functions uses another product called Cloud Build to build the server images that actually get deployed. Those images are stored in Cloud Storage, and that storage is billed to your account.
Read more about it:
https://github.com/firebase/firebase-tools/issues/3404
https://krasimirtsonev.com/blog/article/firebase-gcp-saving-money
Watch:
https://www.youtube.com/watch?v=aHaI0jZ5rwM
You should be able to locate and delete the files manually in the Google Cloud console. But it sounds like there is a bug here with the files not being cleaned up automatically, so you contact Firebase support directly.
For me the issue appeared to be related to my GCF billing (https://console.cloud.google.com/billing)
I had to go to my billing account to see that my payment method was expired or something, and GCF had forecasted a monthly cost of $0.01, so deploying cloud functions was sort of locked until I updated the payment method. Then the deploy immediately worked again after updating it. The build-cleanup console warning also disappeared.
The error I was seeing in my function logs in firebase console was "billing account is not available". Which I found almost zero results for in Google. Which is why I'm posting it here.
For me, the issue was caused by a silly typo.
The error:
Functions deploy had errors with the following functions:
sendNotification(europe-west) i functions: cleaning up build files... ⚠ functions: Unhandled error cleaning up build images. This
could result in a small monthly bill if not corrected. You can attempt
to delete these images by redeploying or you can delete them manually
at...
The fix was choosing the right region.
The incorrect region:
exports.sendNotification = functions
.region("europe-west")...
The correct region:
exports.sendNotification = functions
.region("europe-west3")...
Go to https://console.cloud.google.com/apis/api/artifactregistry.googleapis.com/overview
select your project
enable Artifact Registry API
deploy functions again
In my experience going into Cloud Storage didn't solve the issue: there was no image there to be deleted.
I solved by changing the Node version, moving from 18 to 14.0.0
nvm install 14.0.0
nvm use 14.0.0
Check your Function logs, by either navigating through functions in the Firebase console or through https://console.cloud.google.com/logs
For me, the logs indicated that one of my typescript files had compiled under the wrong name and it was messing up the build.
Check the logs!
General troubleshooting tips given the variety of answers here:
if build is failing, read for other errors further up in the build output
add --debug to your CLI call, i.e.:
firebase deploy --only functions --debug
With --debug I found this in my output: "Permission 'artifactregistry.packages.delete' denied on resource"
My solution was to add Artifact Registry Administrator role to the IAM user deploying the function (in addition to Firebase Admin & Service Account User roles).

Deploying Firebase Functions hit build quota (Build Create requests per minute)

I have a Firebase project with 55 Functions. I sometimes got a deployment error saying that I hit the quota limit for Build Create requests per minute (the quota right now is 60) with the simplest deployment command,
firebase deploy --only functions
And the CLI suggested me to deploy the remaining again using a command like this,
firebase deploy --only functions:functionA,functions:functionB
As it is a per minute quota, I was expecting the CLI to workaround the quota seamlessly. But it's not.
I sent an email to Firebase Support and they advised me to always use only 75% of the quota at one time when trying to deploy functions, but I wonder how everyone workarounds this quota issue ?
I read about organizing functions in groups in the documentation and deploy group-by-group, but I wonder if there is other solutions ?
Well I think that you can use Cloud Build. BTW not sure if you know, that all your Firebase projects and functions are available in GCP as well. You can change and deploy them directly in GCP Console (direct link).
In Cloud Build there is functionality that lets you to deploy to Firebase with convenient configuration file in yaml or json.
The configuration file contain steps of your deploy and you can setup a timeout between them (reference). So, you can create those steps with --only flag with control of time and you can use it created file many times and just adjust it when you add new function.
I think this will help you to avoid hitting quota limits, and I suppose you can use other features of Cloud Build as well.

Firebase deploy fails after adding second project

After adding a second project to my code using the command $ firebase use --add second-project, I get the error
There was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support.
Error: HTTP Error: 404, Could not find Application "second-project".
when I run $ firebase deploy.
I have added separate targets and a web app through Firebase console for the second project.
What should I be checking to get rid of this error?
I just ran into this same exact issue as well. Leaving this here for anyone that runs into this issue in the future. What caused this error for me was a permissions error, when Firebase tried to access specific resources in Google Cloud such as Cloud Functions without the necessary IAM/service accounts in place.
This happens when you create a new Firebase project without setting the Default GCP resource location under Settings > General in the Firebase Console, which occurs when you create a new Firebase project without doing any additional setup. You can set this in the settings or this is also set when you follow the walk-through instructions for setting up services such as Firestore or Firebase Storage in the Firebase console.
Without this set, the <YOUR_FIREBASE_PROJECT_NAME>#appspot.gserviceaccount.com IAM/service account will not be created in Google Cloud (which is needed to create/access specific resources), therefore when you run firebase deploy, it will fail with the error you mentioned above.
You can also check why your firebase deploy is failing in the firebase-debug.log that is generated when running this command (that's how I found out the cause of this error). Though I think this file is deleted after the command finishes execution, so you'll have to pipe the output into a file or save it some other way.
TL;DR: Set Default GCP resource location, one way this can be done is in the Firebase Console under Settings > General.

Cloud Functions deployment failiure from Firebase

I seem to be unable to deploy Google Cloud Functions successfully.
I have created a project on Google Cloud Platform and then proceeded to link it to Firebase via the Firebase console. I select ADD PROJECT and Add Firebase to an existing project. Everything seems to link.
When I try to deploy a cloud function (the simple helloWorld that comes with installing firebase-tools) I keep getting deployment errors. This also happens when trying to deploy functions from Google Cloud Functions dashboard as well.
The error is something aboud setting up the environment.
After ttrying to rename the function to something else, I seem to have luck with deploying but then the function but there is a communication error Function load error: Error: cannot communicate with function.
I am unable to deploy functions on two of my projects, and firebase has been acting very strangely in the last few days, so can somebody please tell me if I am doing something wrong or is it a Firebase glitch
Maybe because there is an outage starting from early this morning. Check status here: https://status.firebase.google.com

Resources