firebase-functions: [Error] V2 functions deployment fails with error in cloud run container service container fails to start
node:
16
firebase-functions:
3.21.2
firebase-tools:
v11.0.1
firebase-admin:
Steps to reproduce
Deploying a single v2 firebase cloud function
// FIREBASE V2 FUNCTION
const { onRequest } = require("firebase-functions/v2/https");
module.exports = onRequest(
{ timeoutSeconds: 1200, region: ["europe-west1"] },
(_req, res) => {
res.status(200).send("OK");
}
);
Expected behavior
Deploy the gen2 firebase cloud function successefully and error free
Actual behavior
Deployment fails, v2 functions are unusable as they simply don’t deploy.
Were you able to successfully deploy your functions?
NO
run > firebase deploy --only functions:function-name
result:
❯ firebase deploy --only functions:webhooks-aifi-v2-checkout
=== Deploying to 'cornershop-app'...
i deploying functions
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔ functions: required API cloudbuild.googleapis.com is enabled
✔ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing codebase default for deployment
i functions: preparing functions directory for uploading...
i functions: packaged /Users/seank/Projects/capgemini/cornershop-app/functions (55.5 MB) for uploading
i functions: packaged /Users/seank/Projects/capgemini/cornershop-app/functions (55.5 MB) for uploading
i functions: ensuring required API cloudscheduler.googleapis.com is enabled...
✔ functions: required API cloudscheduler.googleapis.com is enabled
i functions: ensuring required API artifactregistry.googleapis.com is enabled...
i functions: ensuring required API run.googleapis.com is enabled...
i functions: ensuring required API eventarc.googleapis.com is enabled...
i functions: ensuring required API pubsub.googleapis.com is enabled...
i functions: ensuring required API storage.googleapis.com is enabled...
✔ functions: required API eventarc.googleapis.com is enabled
✔ functions: required API run.googleapis.com is enabled
✔ functions: required API pubsub.googleapis.com is enabled
✔ functions: required API storage.googleapis.com is enabled
✔ functions: required API artifactregistry.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 16 function webhooks-aifi-v2-checkout(europe-west1)...
Could not create or update Cloud Run service webhooks-aifi-v2-checkout, Container Healthcheck failed. Cloud Run error: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.
Logs URL: https://console.cloud.google.com/logs/viewer?project=cornershop-app&resource=cloud_run_revision/service_name/webhooks-aifi-v2-checkout/revision_name/webhooks-aifi-v2-checkout-00001-qur&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22webhooks-aifi-v2-checkout%22%0Aresource.labels.revision_name%3D%22webhooks-aifi-v2-checkout-00001-qur%22
For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start
Functions deploy had errors with the following functions:
webhooks-aifi-v2-checkout(europe-west1)
i functions: cleaning up build files...
Error: There was an error deploying functions
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 16
- Comments: 25 (3 by maintainers)
Hi. I’m sorry I missed this issue.
I re-read the issue thread, and common issue I see is that there are, to one degree or another, some initialization code that contribute to container instance not starting properly on cloud run.
For example, I can replicate the issue
Note that this isn’t chip dependent - the container image deployed to Google Cloud Functions v2 is built on Cloud Build and is not affected by your development machine. Here’s an example:
Note the use of
functions.config
- we do not support using functions config in v2 environment. Instead, we recommend that you use environment variables (https://firebase.google.com/docs/functions/config-env).That being said, this is a very bad footgun. I will brainstorm with the team how we can improve the error message so that it’s clear exactly what’s going on during a function deploy.
Closing the issue as I think the original issue has been identified and resolved.
Same issue happened here. I’m using a MacBook Pro M1 and this page says:
So I guess I’ll have to stick with Functions v1 for now.
Source code:
Output when deploying:
Google Cloud Logging:
Versions:
firebase-functions
: v3.18.1firebase-tools
: v10.2.2@gustavopch It’s wild considering how many companies and users use firebase functions. Would have thought someone from the team at google would have at least replied by now.
Also happened to me on intel chip
I posted on GCP functions framework issues board a while back there was at least some interaction. This lack of inactivity leaves me feeling like we’ve bet on the wrong stack here…
Fingers crossed we get an update and fix soon.
@clementdevos Thanks for the feedback!
Missing documentation is a clear oversight by us. I’ll see if we can add a snippet about this behavior for v2 runtime.
Tangent - on separating v1 and v2 functions; I think you might find the relatively-new codebase feature useful there. Let us know if we an help w/ anything!
I stumbled upon the same issue as @algoflows and after rereading the logs a couple of times, it occurred to me that I was getting the configuration of the function by calling
functions.config
which is not supported in functions v2. The error message is pretty clear on that:I hope this helps.
I got the same issue although I used v2 functions env reference like this. But I am not sure if it is because we have v1 and v2 in one repo. @taeold , having v1 and v2 together in one repo will impact that issue?