On deploy
i got this error
i functions: creating Node.js 18 (2nd Gen) function addCourseData(us-central1)...
Could not create or update Cloud Run service addcoursedata, Container Healthcheck failed. Revision 'addcoursedata-00001-cup' is not ready and cannot serve traffic. 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=PROJECT_ID&resource=cloud_run_revision/service_name/addcoursedata/revision_name/addcoursedata-00001-cup&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22addcoursedata%22%0Aresource.labels.revision_name%3D%22addcoursedata-00001-cup%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:
addCourseData(us-central1)
i functions: cleaning up build files...
with --debug
I got this log
Total Function Deployment time: 67749
[] 1 Functions Deployed
[] 1 Functions Errored
[] 0 Function Deployments Aborted
[] Average Function Deployment time: 67748
Functions deploy had errors with the following functions:
addCourseData(us-central1)
[] Not printing URL for HTTPS function. Typically this means it didn't match a filter or we failed deployment
Functions deploy failed.
[] {
"endpoint": {
"id": "addCourseData",
"project": "PROJECT_ID",
"region": "us-central1",
"entryPoint": "addCourseData",
"platform": "gcfv2",
"runtime": "nodejs18",
"httpsTrigger": {},
"labels": {
"deployment-tool": "cli-firebase"
},
"serviceAccount": null,
"ingressSettings": null,
"availableMemoryMb": null,
"timeoutSeconds": null,
"maxInstances": null,
"minInstances": null,
"concurrency": 80,
"vpc": null,
"environmentVariables": {
"FIREBASE_CONFIG": "{\"projectId\":\"PROJECT_ID\",\"databaseURL\":\"https://PROJECT_ID-default-rtdb.asia-southeast1.firebasedatabase.app\",\"storageBucket\":\"PROJECT_ID.appspot.com\"}",
"GCLOUD_PROJECT": "PROJECT_ID",
"EVENTARC_CLOUD_EVENT_SOURCE": "projects/PROJECT_ID/locations/us-central1/services/addCourseData"
},
"codebase": "default",
"securityLevel": "SECURE_ALWAYS",
"cpu": 1,
"targetedByOnly": true,
"hash": "38475170b79b25f455db5cacbdc1d6c36adc4679"
},
"op": "update",
"original": {
"name": "FirebaseError",
"children": [],
"exit": 1,
"message": "Could not create or update Cloud Run service addcoursedata, Container Healthcheck failed. Revision 'addcoursedata-00001-sox' is not ready and cannot serve traffic. 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.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=PROJECT_ID&resource=cloud_run_revision/service_name/addcoursedata/revision_name/addcoursedata-00001-sox&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22addcoursedata%22%0Aresource.labels.revision_name%3D%22addcoursedata-00001-sox%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start",
"status": 3,
"code": 3
}
}
[] Error: Failed to update function addcourseData in region us-central1
at C:\Users\USER_ABC\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:51:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Fabricator.updateV2Function (C:\Users\USER_ABC\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:380:32)
at async Fabricator.updateEndpoint (C:\Users\USER_ABC\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:153:13)
at async handle (C:\Users\USER_ABC\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:88:17)
Error: There was an error deploying functions
How to fix it? Any help!
My code is
const calledFunctionName = process.env.K_SERVICE;
if (!calledFunctionName || calledFunctionName === "addCourseData") {
const {onRequest} = require("firebase-functions/v2/https");
// Take the email and adds an entry to Firestore with Course data
exports.addCourseData = onRequest(async (request, response) => {
return await (await require("./my-functions/course/add-course-data-function"))
.addCourseData(request, response);
});
}
Everything was working fine before introducing the process.env.K_SERVICE
, so is there anything else to do too, to use the environment variable? As I just added in code to save the cold start and unnecessary file loading.
Why server not able to create a container for the function?
firebase-debug.log
– Triste