firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Unsupported runtime unclear when deploying

Open CorieW opened this issue 6 months ago • 5 comments

[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

  1. Setup firebase project using firebase init
  2. Add "runtime": "nodejs22" to firebase.json under functions
  3. Use test case above as functions code
  4. 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)

CorieW avatar Jun 04 '25 19:06 CorieW

I believe this could break users like myself who have somehow been successfully deploying v1 functions to Node 22. More info here.

jwngr avatar Jun 04 '25 19:06 jwngr

@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.

CorieW avatar Jun 04 '25 20:06 CorieW

Nope, I don't see INVALID_RUNTIME in the output when running firebase deploy --only functions --debug

jwngr avatar Jun 04 '25 22:06 jwngr

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

Image

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.

aalej avatar Jun 05 '25 11:06 aalej

Here are a couple workarounds that might help:

Deploy v1 functions one at a time

  1. Temporarily update the node engines in your functions package.json to version to 20
  2. Deploy only the relevant v1 functions: firebase deploy --only functions:authDelete,functions:authCreate
  3. Change the node version back to 22 and 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.

  1. Model your firebase.json file like this (note the different runtimes depending on the function versions):
{
  "functions": [
    {
      "codebase": "v2",
      "source": "functions",
      "runtime": "nodejs22",
    },
    {
      "codebase": "v1",
      "source": "functionsV1",
      "runtime": "nodejs20",
    }
  ]
}
  1. You may also need to update your package.json node engines to 20 || 22.

Personally, I use the first method, but those using CI/CD may prefer the second.

davidstackio avatar Jun 20 '25 05:06 davidstackio

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.

aalej avatar Oct 14 '25 11:10 aalej