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

Viewed 6830

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?

5 Answers

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.

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")...

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 
Related