18

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?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Odai A. Ali
  • 845
  • 3
  • 8
  • 23
  • I'm having the same problem with a Scheduled Pub/Sub function. It's the only one that fails to be cleaned up – Jean Costa Aug 03 '21 at 19:21
  • I got this error (Unhandled error cleaning up build images. This could result in a small monthly bill if not corrected.....) even after I updated my firebase-cli to 9.16.0. It turns out that there was a pending payment for my account at Google Cloud Platform. Once I did the payment, I am able to do a firebase deploy. Weird huh???? – Siva Aug 18 '21 at 07:09
  • @JeanCosta Did you find a solution for this? – AfromanJ Mar 30 '22 at 14:51
  • @AfromanJ , I don't recall the specifics for this, but I recall that the problem was somewhere else. You fix the other problem, and this will get fixed. Make sure to take a look at the firebase.debug log file in your functions folder after trying a deployment, and also make sure to check the logs in the Firebase Console -> Functions -> Logs, since those complement one another. You will likely find the issue there – Jean Costa Mar 31 '22 at 15:14

8 Answers8

11

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:

Watch:

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.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • 4
    Looks like credit card expiration was behind this, I fixed it then I was able to deploy function . But should I be worried about the cost it may cause if not cleaning up these files, will the cost exponentially grow?, Would Upgrading Firebase CLI solve it by removing these temporary files created after deploying as Frank van Puffelen mentioned in this video https://www.youtube.com/watch?v=aHaI0jZ5rwM – Odai A. Ali Aug 01 '21 at 16:41
  • 1
    The cost grows linearly (~$0.003 per GB). Check out https://cloud.google.com/storage/pricing for exact pricing. You are probably already using the version of the CLI that deletes images after deploy. If you are worried about large bills (unlikey for most users), go ahead and delete them manually by visiting Google Cloud console for Container Registry. – Daniel L Aug 02 '21 at 17:02
  • Previously (some month ago) I have doing deploy of functions w/o any warnings use free Spark plan, now I got "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-functions/us/gcf Function URL (app(us-central1)): https://us-central1-project-functions.cloudfunctions.net/app" I have deleted them but still got this error. Is really billing required for now? – CodeBy Aug 07 '21 at 08:48
  • On the Google Cloud Platform - Cloud Functions page (https://console.cloud.google.com/functions/list?project=project-functions&authuser=2) there is my app function with red exclamation sign and popup "Unknown functions status" – CodeBy Aug 07 '21 at 09:20
  • 1
    I'm using GOOGLE_APPLICATION_CREDENTIALS for firebase deploy in ci. What roles does the service account need to properly deploy? Firebase Admin is not sufficient because cloud scheduler cloud functions fail with the OP error. – Leblanc Meneses Dec 17 '21 at 03:14
7

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.

SeanMC
  • 1,960
  • 1
  • 22
  • 33
2

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")...
Amer NM
  • 159
  • 2
  • 7
1
  1. Go to https://console.cloud.google.com/apis/api/artifactregistry.googleapis.com/overview
  2. select your project
  3. enable Artifact Registry API enter image description here
  4. deploy functions again
GorvGoyl
  • 42,508
  • 29
  • 229
  • 225
  • Enabling this costs me more than 49$ per week, how to avoid this kinda issue? – Joel Jerushan Oct 09 '22 at 11:09
  • Could you pinpoint the exact cause of that? if it's related to storing backups, then you can schedule them to delete or keep max 3 versions etc – GorvGoyl Oct 09 '22 at 12:49
  • ```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``` i'm getting an error message like this – Joel Jerushan Oct 11 '22 at 15:45
1

General troubleshooting tips given the variety of answers here:

  1. if build is failing, read for other errors further up in the build output
  2. 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).

nsolent
  • 113
  • 1
  • 5
1

You can try to delete your function file from Artifact Registry > gcf-artifacts of your project then delete your function. It worked for me!!

PS. You will get a link to your registry in error open that then click on your project name from Breadcrumb then see the gcf-artifact repo which you can check by seeing the location column which matches yours or you can open each one and see name of your function there > open it and delete the last deploy function from there.

Shubhanker
  • 11
  • 2
0

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 
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!

Ric Barnes
  • 23
  • 4