I'm failing to deploy my Firebase function to another region, it's only successful when I use us-central1 (default region). Previously, I have successfully deployed this function to australia-southeast1 multiple times.
Here is my code:
export const sendWelcomeEmail = functionsV1
.region("us-central1")
.auth.user()
.onCreate((user) => {
if (!sendGridApiKey) {
logger.info("Missing Send Grid API key");
throw new Error("Missing SENDGRID_API_KEY in environment variables");
}
sgMail.setApiKey(sendGridApiKey);
const msg = {
to: user.email,
from: "tech@lemongrassproductions.co.nz",
templateId: "d-715ec7a4d4414d23a294d2b3c5a7f684",
dynamic_template_data: {
name: user.displayName,
email: user.email,
},
};
sgMail
.send(msg)
.then((response) => {
logger.info(response[0].statusCode);
logger.info(response[0].headers);
})
.catch((error) => {
logger.info(error);
});
});
Log error message when I deploy with --debug
[info] i functions: creating Node.js 22 (1st Gen) function sendWelcomeEmail(australia-southeast1)...
[info] + functions[flicketWebhookHandler(australia-southeast1)] Skipped (No changes detected)
[debug] [2025-05-10T01:54:21.284Z] Checked if tokens are valid: true, expires at: 1746844684528
[debug] [2025-05-10T01:54:21.284Z] Checked if tokens are valid: true, expires at: 1746844684528
[debug] [2025-05-10T01:54:21.285Z] >>> [apiv2][query] POST https://cloudfunctions.googleapis.com/v1/projects/winetopia-db6ec/locations/australia-southeast1/functions [none]
[debug] [2025-05-10T01:54:21.285Z] >>> [apiv2][body] POST https://cloudfunctions.googleapis.com/v1/projects/winetopia-db6ec/locations/australia-southeast1/functions {"name":"projects/winetopia-db6ec/locations/australia-southeast1/functions/sendWelcomeEmail","sourceUploadUrl":"https://storage.googleapis.com/uploads-704684574651.australia-southeast1.cloudfunctions.appspot.com/02ea1e5f-c7f2-4dc1-936b-ecbe19beea70.zip?GoogleAccessId=service-982256841444@gcf-admin-robot.iam.gserviceaccount.com&Expires=1746843864&Signature=B5AqP%2Fo7UPzhzIYd7zj4IinzFnwmBZgbNbYI0ZEralGy0CDtPmE8EbTxXo5gdoT55%2B1eeB%2FpwPS%2BH%2BGXwVky%2BsK1qOA7Ou%2FqSFANX9o2%2F1DqfeK03q9m156XAPL4WlZ6lmzCHWpputC0ntprQGG6hWtLYwDfJrEFh0f4gwnYfoFGJ9lnk2IHu7jvz5v8w%2F%2FrK%2FkrX6qTSe%2F3TPicAVxEKJh%2Bh9SDy9tZ5y4BMPKYTgHeLw4uyLhN%2FCcBHC%2F5Cz36VyWPPLr70lDuoIUuGgnPuDHmADVD5D0RqmaTF9r2VTO%2BDhNosac1Je5r6DGcWBdb3q9fYTwopSbEk%2FHKakFLsQ%3D%3D","entryPoint":"sendWelcomeEmail","runtime":"nodejs22","dockerRegistry":"ARTIFACT_REGISTRY","labels":{"deployment-tool":"cli-firebase","firebase-functions-hash":"6b72c870bd6e3131eed7f1b862a26ae665083c1e"},"eventTrigger":{"eventType":"providers/firebase.auth/eventTypes/user.create","resource":"projects/winetopia-db6ec"},"minInstances":null,"maxInstances":null,"ingressSettings":null,"environmentVariables":{"SENDGRID_API_KEY":"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","WINETOPIA2025_EVENT_ID":"39d1bce3-ad5b-41fb-8a41-aadee4d239b9","FIREBASE_CONFIG":"{\"projectId\":\"winetopia-db6ec\",\"storageBucket\":\"winetopia-db6ec.firebasestorage.app\"}","GCLOUD_PROJECT":"winetopia-db6ec","EVENTARC_CLOUD_EVENT_SOURCE":"projects/winetopia-db6ec/locations/australia-southeast1/functions/sendWelcomeEmail"},"serviceAccountEmail":null,"availableMemoryMb":null,"timeout":null,"vpcConnector":null,"vpcConnectorEgressSettings":null,"buildEnvironmentVariables":{"GOOGLE_NODE_RUN_SCRIPTS":""}}
[debug] [2025-05-10T01:54:21.843Z] <<< [apiv2][status] POST https://cloudfunctions.googleapis.com/v1/projects/winetopia-db6ec/locations/australia-southeast1/functions 400
[debug] [2025-05-10T01:54:21.843Z] <<< [apiv2][body] POST https://cloudfunctions.googleapis.com/v1/projects/winetopia-db6ec/locations/australia-southeast1/functions {"error":{"code":400,"message":"Failed to create 1st Gen function projects/winetopia-db6ec/locations/australia-southeast1/functions/sendWelcomeEmail: runtime: Runtime validation errors: [error_code: INVALID_RUNTIME\nmessage: \"Runtime \\\"nodejs22\\\" is not supported on GCF Gen1\"\n]","status":"INVALID_ARGUMENT"}}
[warn] ! functions: failed to create function projects/winetopia-db6ec/locations/australia-southeast1/functions/sendWelcomeEmail
[error] Failed to create function projects/winetopia-db6ec/locations/australia-southeast1/functions/sendWelcomeEmail
[debug] [2025-05-10T01:54:21.850Z] Total Function Deployment time: 563
[debug] [2025-05-10T01:54:21.850Z] 1 Functions Deployed
[debug] [2025-05-10T01:54:21.851Z] 1 Functions Errored
[debug] [2025-05-10T01:54:21.851Z] 0 Function Deployments Aborted
[debug] [2025-05-10T01:54:21.851Z] Average Function Deployment time: 562
[info]
[info] Functions deploy had errors with the following functions:
sendWelcomeEmail(australia-southeast1)
[debug] [2025-05-10T01:54:22.138Z] Not printing URL for HTTPS function. Typically this means it didn't match a filter or we failed deployment
[debug] [2025-05-10T01:54:22.139Z] Checked if tokens are valid: true, expires at: 1746844684528
[debug] [2025-05-10T01:54:22.139Z] Checked if tokens are valid: true, expires at: 1746844684528
[debug] [2025-05-10T01:54:22.139Z] >>> [apiv2][query] GET https://artifactregistry.googleapis.com/v1/projects/winetopia-db6ec/locations/australia-southeast1/repositories/gcf-artifacts [none]
[debug] [2025-05-10T01:54:23.120Z] <<< [apiv2][status] GET https://artifactregistry.googleapis.com/v1/projects/winetopia-db6ec/locations/australia-southeast1/repositories/gcf-artifacts 200
[debug] [2025-05-10T01:54:23.120Z] <<< [apiv2][body] GET https://artifactregistry.googleapis.com/v1/projects/winetopia-db6ec/locations/australia-southeast1/repositories/gcf-artifacts {"name":"projects/winetopia-db6ec/locations/australia-southeast1/repositories/gcf-artifacts","format":"DOCKER","description":"This repository is created and used by Cloud Functions for storing function docker images.","labels":{"goog-managed-by":"cloudfunctions"},"createTime":"2025-04-21T22:41:53.981756Z","updateTime":"2025-05-10T00:52:24.211757Z","mode":"STANDARD_REPOSITORY","cleanupPolicies":{"firebase-functions-cleanup":{"id":"firebase-functions-cleanup","action":"DELETE","condition":{"tagState":"ANY","olderThan":"86400s"}}},"sizeBytes":"148912604","satisfiesPzs":true,"vulnerabilityScanningConfig":{"lastEnableTime":"2025-04-21T22:41:42.885613073Z","enablementState":"SCANNING_DISABLED","enablementStateReason":"API containerscanning.googleapis.com is not enabled."},"satisfiesPzi":true,"registryUri":"australia-southeast1-docker.pkg.dev/winetopia-db6ec/gcf-artifacts"}
[debug] [2025-05-10T01:54:23.120Z] Functions deploy failed.
[debug] [2025-05-10T01:54:23.121Z] {
The problem as reported in the error message of your log doesn't seem to have anything to do with region. It seems to do with the choice of runtime. Here is the specific message:
Failed to create 1st Gen function .../sendWelcomeEmail: runtime: Runtime validation errors: [error_code: INVALID_RUNTIME message: Runtime nodejs22 is not supported on GCF Gen1]
You're trying to deploy a gen1 function using the nodejs22 runtime. This isn't supported by Cloud Functions. You can see a table of supported runtimes in the Google Cloud documentation. You will see that node 22 is only supported for gen2 functions, while node 20 is the latest available for gen1.
This has been discussed on GitHub - you should read that to better understand how things work. A solution was given here to change to a supported runtime:
For those stuck on this, specify
"nodejs20"
as the Functionsruntime
in yourfirebase.json
:[ "functions": [ { "runtime": "nodejs20", // Other existing Functions config... } ], // Other existing firebase.json config... ]
You can find the relevant docs here.
For the Firebase team, it would be nice if the Gen1/2 Node versions moved in lockstep. Even better if Gen1 functions like the auth ones were just offered as Gen2 functions.