Fix error messages when deploying Functions
Several error messages often occur when deploying Firebase Cloud Functions that should not occur. My first time attempting to deploy functions in a new project, I got:
i extensions: ensuring required API firebaseextensions.googleapis.com is enabled...
⚠ extensions: missing required API firebaseextensions.googleapis.com. Enabling now...
Error: Request to https://serviceusage.googleapis.com/v1/projects/********/services/firebaseextensions.googleapis.com had HTTP Error: 429, Quota exceeded for quota metric 'Default requests' and limit 'Default requests per minute' of service 'serviceusage.googleapis.com' for consumer 'project_number:********'.
I don't know if that happens every time. It appears to be just a failure to wait long enough after enabling the API.
The second time, it got further, but errored again:
⚠ functions: missing required API eventarc.googleapis.com. Enabling now...
✔ functions: required API pubsub.googleapis.com is enabled
✔ functions: required API storage.googleapis.com is enabled
✔ functions: required API run.googleapis.com is enabled
✔ functions: required API eventarc.googleapis.com is enabled
i functions: generating the service identity for pubsub.googleapis.com...
i functions: generating the service identity for eventarc.googleapis.com...
✔ functions: functions folder uploaded successfully
i functions: creating Node.js 22 (2nd Gen) function onMessageCreated(us-central1)...
⚠ functions: Request to https://cloudfunctions.googleapis.com/v2/projects/********/locations/us-central1/functions?functionId=onMessageCreated had HTTP Error: 400, Validation failed for trigger projects/*****/locations/us-central1/triggers/onmessagecreated-119882: Invalid resource state for "": Permission denied while using the Eventarc Service Agent. If you recently started to use Eventarc, it may take a few minutes before all necessary permissions are propagated to the Service Agent. Otherwise, verify that it has Eventarc Service Agent role.
⚠ functions: Since this is your first time using 2nd gen functions, we need a little bit longer to finish setting everything up. Retry the deployment in a few minutes.
⚠ functions: failed to create function projects/**/locations/us-central1/functions/onMessageCreated
Failed to create function projects/*****/locations/us-central1/functions/onMessageCreated
Functions deploy had errors with the following functions:
onMessageCreated(us-central1)
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 https://console.cloud.google.com/gcr/images/********/us/gcf
Error: There was an error deploying functions
Again, it appears to be a timeout issue.
Subsequent deploys have been successful, but I get this warning every time:
⚠ 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 https://console.cloud.google.com/gcr/images/********/us/gcf
That implies there may be a storage leak happening on every deploy.
None of these errors should be happening, as far as I can tell.