Cloud Functions Deployment Error build step 3 - firebase

Just recently I am starting to experience an issue when trying to deploy my functions through Firebase. When running the command firebase deploy --only functions one of my four functions deploy correctly, but the other three throw this error in the firebase-tools console:
Deployment error.
Build failed: Build error details not available. Please check the logs at url to my GCP logs
When I look at the logs the error message that shows for each function that is failing is:
ERROR: build step 3 "us.gcr.io/fn-img/buildpacks/nodejs10/builder:nodejs10_20200922_20_RC00" failed: step exited with non-zero status: 46
I have searched and googled for quite a while now and I cannot find anyone reporting the same error code, having the same non-zero status returned, or having functions fail on step 3. There doesn't seem to be much for documentation on troubleshooting the errors either.
Hopefully someone here can point me in the right direction.
Thanks!

The error seems to be caused by a missing (or not accessible) file in the history/restore functionality of Firebase. Don't know the reason for this.
A workaround that worked for me was:
Remove the functions in the web console
Deploy normally > firebase deploy

Answering since I can't comment in response to xaphod, Markus's fix worked for me, thank you mate! Deleting the function means it creates a new one rather than trying to restore it, which is the failed step 3 in the build process.
In response to xaphod, I did setup a lifecycle rule for old files in the artifacts bucket, it was by far my biggest bucket in storage and was pushing the free tier limit. I set it up a bit short probably, delete 5 days after last updated time, but surprisingly didn't run into this issue until today (possibly because I usually just deploy them all whenever I update one). I removed the lifecycle rule for now, although I'd rather it not run up the storage space again, I might end up contacting support to see if there's a way to lifecycle them without deleting the most recent, not sure why it doesn't just clear out the old images on updates though.
Found the post that suggested setting up lifecycle rules, firebase storage artifacts is huge, and did some testing as well, deleted all the files in us.artifacts and deployed all my functions (got errors on all them, only deleted the function that I needed to update earlier and deployed it by itself). Doesn't cause any errors, just takes a bit longer, so I think the issue can be fixed by deleting them all or deleting nothing, probably going to set the lifecycle rule to delete immediately and deal with the increased deploy time, rather than the cost of firebase storage.

Related

Run into "Internal error occurred while performing container health check" when deploying with Gcloud

So I'm very new with gcloud (cloud in general). Please assume me as a very beginner. So I know how to create image, but I have a problem with deploying. It kept running forever with this message:
X Deploying... Internal error occurred while performing container health check.
- Creating Revision... Revision deployment finished. Waiting for health check to begin.
. Routing traffic...
OK Setting IAM Policy...
Aborted by user.
In the Vscode, my app using the django framework run on the local server works perfectly fine. One thing I notice that because I kept running into the error when deploying, I tried many time to delete the current project and create a new project and create new image with the new project; therefore, I have a lot of images in https://gcr.io/cloud-builders/docker. I notice this because it said "something" already existed every time I deployed. But I don't know how to delete them because:
You need permissions for this action.
Required permission(s): storage.objects.delete
I don't know what happen here. I need help this for my bootcamp project. Also, please explain with basic tech terms because I'm really new to this. Thanks alot!

How to debug the absence of hydration in a nextjs page?

Background:
We are have noticed that in production and in some staging environments, that the onClick handlers on a SSR page are failing to be called. By comparing working and non-working (npm run start) deployments we've determined that the non-working deployments are not calling the render() methods of the components on the page immediately after page reload, whereas the working deployments do. We are assuming that means that hydration is not occurring.
Development deployments (npm run dev) work flawlessly
We are seeing no browser-side console messages.
We are seeing no server side warnings
The npm build --debug suggests only to upgrade to the new ChunkGraph API. Otherwise no warnings.
We are now wondering...
QQ:
Short of starting with a fresh create-next-app again and gradually evolving the app towards our current implementation until it breaks, what are the suggested ways of determining the root cause(s) of a problem like this?
For some reason, my hydration issues only showed up in production, and only on the server. Running next build and next start didn't show any errors. Since user3624334's answer didn't really help me, I figured I'd reply with how I ended up finding the culprit.
Since I deploy to Vercel, and use Vercel's review apps, I ended up creating a Pull Request where I remove half of the page that was having the hydration issues, and continued bisecting until I found out which component was causing the issues. It took me three tries to find the component.
Once I had the component it was quite easy to figure out what was causing the issues (for me the hydration issue was caused by a timestamp being rendered in different ways).
This also explains why user3624334's answer didn't work for me, since I opened the page straight after building, at which point the time was still the same as during next build!
One challenge here is that it appears that when SSR page hydration fails in next.js, a warning message will not necessarily be generated.
I hope someone has a better suggestion than the following, but I will offer this human script that worked several times for me:
git checkout -b "hydration-problem-02" to create a branch for this effort
add a console.log('render called') to the top of the render() method of pages/_app.js. This should produce a message on each hydrate, making it easy to notice when the page does/does-not hydrate.
Then repeatedly:
simplify a significant portion of the app.
npm run dev to run in dev mode
confirm that your change did not break the app in unexpected ways
rm .next/ node_modules/ package-lock.json
npm install && npm run build && npm run start
confirm that the above command completed successfully
refresh the page in the browser
check for the message in the browser console.
git commit -am "msg that indicates what you changed and if it helped"
if the problem remains, repeat these steps
Doing the commits above should help make the process more fool-proof. Ex. If you think you might have forgotten to test in production mode, you can go back to that commit and retest to confirm you did not mis-test.
Once you have a working and non-working commit of the app, you can do a binary search for the error, either adding or removing smaller and smaller pieces of function.
The root causes of quiet hydration failures I've seen include:
two modules that mutually import each other
an import '..../bootstrap.js' in a component rather than _app.js

Why am I no longer able to deploy functions (Error 503)?

No longer able to deploy cloud function via "firebase deploy" command - receiving error: "HTTP Error: 503, The service is currently unavailable"
I previously had a single function deployed and working until a slight modification was causing an authentication error, so I temporarily deleted it until I had time to fix the error.
So a couple days pass, I modify the original code (just added a bit of code relating to service account credentials, didn't even modify the actual function) and tried to re-deploy it (using 'firebase deploy') however it's throwing the following error: "HTTP Error: 503, The service is currently unavailable".
I thought maybe the service is currently down, but Firebase Status Dashboard shows all services are green and noone else seems to be complaining about this error at the moment. I've tried reinstalling/updating firebase-tools and even reverting the functions index.js code back to what it had been when I last successfully deployed, but same error every time. I don't think it has anything to do with the code on my end, but perhaps some weird bug relating to my account/api/authentication.
I've submitted a tech support question on firebase and am awaiting response, but thought I'd try my luck here as well.
Any suggestions?
After some back and forth with firebase technical support, turns out it is some strange bug on their server end (in relation to this particular project) as I'm able to deploy the same functions no problem to other projects. It may have been "triggered" initially by hitting a function invocation quota when I was having issues with one of the functions in the past (an issue which somehow caused the function to be repeatedly called until I realized and deleted it 2 days after). However the project should no longer be limited and I still am unable to deploy any functions on that particular project.
The issue has been handed onto their engineers and hopefully will have it resolved on their end soon.

Firebase Functions: "Failed to get status of functions deployments"

I am getting a very strange error when I attempt to deploy my firebase functions.
As a test to rule out my code, I deleted everything except the require(firebase-functions); statement in my index.js file and then tried to deploy, but I again received the same error message:
Error: Failed to get status of functions deployments.
It also prompts me to see my function log file, but there is nothing new or relevant outputted there. Anyone have any idea how to fix this?
Please be sure you have the right nodejs version. Also for any issue regarding firebase product, the status can be checked in this link:
https://status.firebase.google.com/
The above link will provide a status for each service.
When the issue gets solved, you can just deploy your functions again with a different name instead of deleting or just redeploy them.
Edit:
Currently in the link above the issue is listed there, there is currently Service Disruption.
Please check this:https://status.firebase.google.com/incident/Functions/18003
to know when this issue will be solved as the firebase team has seen that there is a problem.
firebaser here
There is an ongoing issue with deploying Cloud Functions through the Firebase CLI. To track its status, look a the Firebase status page.
Update: the issue was fixed at 7:22 am PST.
I just successfully deployed some of my own functions, which was failing earlier. Thanks for your reports and patience everyone!
I was getting this error when there were no deployment issues mentioned on the status page.
It turned out that the project just needed to "Link a billing account".
This can be done via the Billing section on Google Cloud Platform.

Why are my Firebase Functions deploys (from the Netherlands) failing?

Update: The problems passed for a while, but then returned with a vengeance since yesterday. Deploys now really take forever and always fail with Server Error. connect ETIMEDOUT or Upload Error: Cannot read property 'response' of undefined or something else.
After experimenting with connecting via a US location using HideMyAss I found that that completely resolved my issues though! Note that this issue not only occurs when deploying from our office in Amsterdam, but also from our office in Rotterdam. In the meanwhile I have also heard from more people experiencing issues with other Google services.
I have replied to the related Firebase Support email with this information and hope they will look into it. In the meanwhile I guess I'll have to keep on using HideMyAss..
--
Deploying Functions has been taking increasingly longer times after adding more of them. Occasionally at first, but recently for some periods every time I try to $ firebase deploy --only functions one of the functions being deployed at random fails with:
⚠ functions[foo]: Deploy Error: Failure in the
execution environment
When I try again an hour or so later it deploys without a problem (still takes 2 minutes to deploy which seems a little slow).
Perhaps the deploy process is timing out; it always fails after a long time, never quickly.
Perhaps my location outside of America is resulting in latency related issues in the deployment process? Doesn't seem very likely though..
I'm also looking into Firebase Functions logging "Function execution took 60002 ms, finished with status: 'timeout'" and other performance issues, so I wonder if these are all related.
PS: I also reported this to https://firebase.google.com/support/ but the last report I made there is still un-answered after 15 days, so I'm going to go ahead and post it here as well. I included a firebase-debug.log with that report, but rather not publicly sharing that here (not sure if there any tokens in there etc).
Also having issues
I have been having similar issues today and I am deploying from the United States.
For example a function will fail showing these two errors:
Deploy Error: Failure in the execution environment
Error: Functions did not deploy properly.
I found that once when this happened it was because my internet connection was dropping and then totally dropped during a firebase deploy.
Then again it happened because I was trying to deploy at the exact same time that at lot of my cloud functions happened to kick off doing stuff on their servers.
Once the cloud function had failed, then even when my internet resumed and my functions weren't busily running, it would not let me redeploy to get the jammed function running again. No matter what the broken copy of it was stuck in their servers with the tag:
Failure in execution environment
My Solution
I found that once you have a problem like that you can actually rename the function. On the next deploy it will effectively delete the old broken function and reload it as a working copy with the new name.
I would think if your project required it to have the same name you could do this process one more time, deleting the copy with the new name and restoring the copy with the name you needed. Or even block commenting out the function to delete it on the first deploy and then uncommenting it on another deploy to reinstall it.
How that helps you
I'm hoping that if you are still having issues from the Netherlands it is helpful to know that it may be a slow connection issue or a busy server issue. As I have found these two things to cause problems for me from within the States.
Also my solution of deleting and redeploying the function might help to speed up a deploy if the issue is with a copy that is on their servers. It would be interesting to know if that helps because even though the function looks ok on the server maybe it had issues during the previous deploy that are jamming up future deploys.
Sorry for the late response to this, hopefully you are no longer having these issues with firebase (I hate firebase btw, always issues like this).

Resources