firebase-functions: Cloud Functions not deploying: Build fails
Version info
node: v10.18.1 (Issue is present irrespective of version)
firebase-functions: 3.6.1 (Issue is present irrespective of version)
firebase-tools: 8.12.1 (Issue is present irrespective of version)
firebase-admin: 9.2.0 (Issue is present irrespective of version)
Steps to reproduce
I’ve been trying to deploy my existing project with just a few EJS changes. But it doesn’t deploy even if I redeploy old code.
Expected behavior
Should deploy
Actual behavior
{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":13,"message":"Build failed: Build error details not available. Please check the logs at https://console.cloud.google.com/logs/viewer?project=[Name removed]&advancedFilter=resource.type%3Dbuild%0Aresource.labels.build_id%3D[ID removed]%0AlogName%3Dprojects%2F[Name removed]%2Flogs%2Fcloudbuild"},"authenticationInfo":{"principalEmail":"[Email removed]"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/[Name removed]/locations/us-central1/functions/app"}
Were you able to successfully deploy your functions?
No, I ended up with this:
⚠ functions[app(us-central1)]: Deployment error.
Build failed: Build error details not available. Please check the logs at https://console.cloud.google.com/logs/viewer?project=[Name removed]&advancedFilter=resource.type%3Dbuild%0Aresource.labels.build_id%3D[ID Removed]%0AlogName%3Dprojects%2F[Name removed]%2Flogs%2Fcloudbuild
Functions deploy had errors with the following functions:
app
To try redeploying those functions, run:
firebase deploy --only "functions:app"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 111 (15 by maintainers)
I fixed it by deleting us.artifacts.[Project ID].appspot.com
Updating Node JS to version 16 work for me
"engines": { "node": "16" },
You kind sir. Thank you very much. Worked like a champ. Wish i discovered your solution earlier, wasted 4 hours on this issue. Thank you!
Thanks. This worked
@aravindvnair99, The issue is still occurring after deleting the bucket
where is this file
Please file a support ticket at firebase.google.com/support
Reply for 1st part
@taeold Yes, it does. That was the error. Tried checking earlier logs, but I was unable to find them. But as far as I remember, it is the same thing. But I checked for a few recent ones, and I noticed Cloud Functions says something like:
Clicking on the link it gives, takes me to the build details where I can see that step 2 titled “analyzer” is failing :
Reply for 2nd part
The issue is the same for most people I believe (I have gone through multiple reports online and I have also helped many who approached me directly face to face / social media platforms). I first faced this issue and then opened this issue tracker on October 15th, 2020. I managed to figure it out on my own and closed it. And for me, the issue came up because I had set a life cycle for the cloud storage on my own. I did so as I ended up getting much higher-than-expected costs for Cloud Storage. Deleting the bucket fixed it for me as I mentioned here: https://github.com/firebase/firebase-functions/issues/795#issuecomment-710091616 and that was a one-time thing for all my projects sitting on Firebase. Also, this was only for Node.js 8 and 10. Node.js 12 did not seem to have this issue back then when I checked.
Later as time passed, I noticed Google was auto adding life cycles, especially to newer projects which was never the case before. So, I stopped manually setting it up. Everything was fine until now where suddenly everyone is facing issues. It is something that changed during that time that is causing the issue and that is when I opened https://github.com/firebase/firebase-tools/issues/3359 and is now occurring irrespective of the Node.js version. It has always been the Cloud Build that is failing due to the life cycle policies. Some recent change to the build process is what’s causing all these issues. Deleting the bucket always fixes it for me. I have not tried deleting images yet. But as far as I can see, it’s the life cycle that is creating issues for most people.
Related issues:
Apart from the ones I listed, Stack Overflow is filled with questions related to:
Concluding thoughts
But with that said, I feel properly documenting all necessary information in the right place and auto-deleting / cleaning up unnecessary stuff in the right manner after deployment should solve this issue for most if not all people because as far as I have seen, most people have life cycle policies set either manually or automatically from Google’s end. I also feel duplicate issues can be closed so that everything can be tracked in a single place.
Hey @i-am-mani!
You just have to delete the contents of the bucket by selecting the main folder and then redeploy. If that doesn’t help, then delete the bucket and it will automatically create it again for you on the next deployment. Things should be fine then.
@inlined you are right. I am paid customer and forgot about the the support because I went through the support in Google Cloud dashboard instead Firebase Console.
Yes, I fixed!
Fixed? I don’t see a log file anywhere. I’ll repeat again that this is a forum for reporting bugs, not troubleshooting general deploy problems. We have many more people employed to help you with the latter than the former. You’ll find very qualified support at your disposal at firebase.google.com/support.
@aravindvnair99 ok fixed
@faustoct what’s the issue you are facing?
Solved by downgrading Node js version to 12 and CLI also upgraded.
FYI: The staging bucket is a Google-created bucket that was originally used for App Engine uploads. It always has a lifecycle policy because it’s only expected to be used by Google tools and those tools aren’t ever supposed to be putting durable objects there (it is, after all, only a “staging” bucket). IIRC we stopped using the staging bucket for GCF a long time ago, so any issues involving the staging bucket should probably be closed with “upgrade your CLI”.
Google Container Repository does not handle deleting the underlying GCS files cleanly. Adding a lifecycle hook will cause GCF and other tools to break. Any issues involving the artifacts bucket should probably be closed with “Don’t mess with the artifacts bucket. Upgrade your CLI and we will safely purge caches for you”
Are there other outstanding issues that could be considered in-scope, or can this bug be closed? As @taeold commented, “not deploying” is too broad a scope for a single bug. Issues related to container registry failures fit here. Other specific issues/bugs can be new GitHub issues. If you can’t narrow down your trouble deploying to any particular bug, contacting support will probably get you going faster
Also - consider upgrading your firebase cli to 9.14.0. We just shipped a feature where container images will be cleaned up after a successful function deploy!
https://github.com/firebase/firebase-tools/pull/3439
@i-am-mani Emptying the artifacts is usually more than sufficient. If that doesn’t work (like in my case), then delete the artifacts bucket. If that also doesn’t work, empty the sources bucket. If that also doesn’t work, then delete the sources bucket. It will automatically recreate as needed on deploy.
it does not work for me. for my issue, it’s because of
require('../service-account-file.json')
, so I need to remove allrequire
https://stackoverflow.com/a/62855195/4340131hey @aravindvnair99 i debug it. Thank you again for your help!! Take care man!
debug.txt @aravindvnair99 firebase --debug deploy