firebase-tools
firebase-tools copied to clipboard
Unsupported runtime unclear when deploying
[REQUIRED] Environment info
firebase-tools: 14.4.0
[REQUIRED] Test case
import { onRequest as onRequestV2 } from "firebase-functions/v2/https";
import { onRequest as onRequestV1 } from "firebase-functions/v1/https";
export const issue1653_v2 = onRequestV2((req, res) => {
res.send("Hello from Firebase v2!");
});
export const issue1653_v1 = onRequestV1((req, res) => {
res.send("Hello from Firebase v1!");
});
[REQUIRED] Steps to reproduce
- Setup firebase project using
firebase init - Add
"runtime": "nodejs22"to firebase.json underfunctions - Use test case above as functions code
- Run
firebase deploy --only functions
[REQUIRED] Expected behavior
A clear message indicating that the runtime is unsupported for GCF Gen1
[REQUIRED] Actual behavior
Fails without any indication as to why (unless running with --debug flag)
I believe this could break users like myself who have somehow been successfully deploying v1 functions to Node 22. More info here.
@jwngr Do you receive the following error when using the --debug flag?
Runtime validation errors: [error_code: INVALID_RUNTIME\nmessage: \"Runtime \\\"nodejs22\\\" is not supported on GCF Gen1\"\n]",
"status": 400
},
"status": 400,
"code": 400
}
I believe firebase-tools could just handle the error by logging a readable user message. With this approach, you shouldn't be affected.
Nope, I don't see INVALID_RUNTIME in the output when running firebase deploy --only functions --debug
Thanks for the detailed report @CorieW! I’m able to reproduce the issue. Reading though #1653, I’m not sure how folks were able to deploy 1st gen functions with nodejs22 even though it's not listed as a valid runtime in https://cloud.google.com/functions/docs/runtime-support#node.js
I think on the Firebase CLI side, we should throw a better error indicating that 1st gen functions do not support nodejs22. Though, let me check this first with our engineering team. As @jwngr mentioned, this might break the set up of folks who seem to have already deployed 1st gen functions with nodejs22.
Sharing the mcve here.
Here are a couple workarounds that might help:
Deploy v1 functions one at a time
- Temporarily update the node engines in your functions
package.jsonto version to20 - Deploy only the relevant v1 functions:
firebase deploy --only functions:authDelete,functions:authCreate - Change the node version back to
22and deploy the rest of your v2 functions.
Create two separate codebases for your functions
This isn't technically the advertised "side by side" (as it requires two directories of functions you need to maintain), but it lets you manage them within one project. See the docs to learn about codebases.
- Model your
firebase.jsonfile like this (note the different runtimes depending on the function versions):
{
"functions": [
{
"codebase": "v2",
"source": "functions",
"runtime": "nodejs22",
},
{
"codebase": "v1",
"source": "functionsV1",
"runtime": "nodejs20",
}
]
}
- You may also need to update your
package.jsonnode engines to20 || 22.
Personally, I use the first method, but those using CI/CD may prefer the second.
Hey folks, Node.js 22 support for 1st gen functions was recently released! You should now be able to deploy 1st gen functions with the nodejs22 runtime. See these docs for reference:
- https://firebase.google.com/docs/functions/1st-gen/manage-functions-1st#1g-set-node.js
- https://cloud.google.com/functions/docs/runtime-support#node.js
I'll go ahead and close this issue, but if you're still encountering an error when deploying 1st gen functions that use Node.js 22, please leave a comment so that we can reopen this.