Skip to content

fix(deploy): target Node 22 and the firebase-functions/v1 API in generated Cloud Functions - #3743

Merged
armando-navarro merged 3 commits into
angular:mainfrom
armando-navarro:fix/generated-function-runtime
Aug 12, 2026
Merged

fix(deploy): target Node 22 and the firebase-functions/v1 API in generated Cloud Functions#3743
armando-navarro merged 3 commits into
angular:mainfrom
armando-navarro:fix/generated-function-runtime

Conversation

@armando-navarro

Copy link
Copy Markdown
Collaborator

Checklist

Description

Fixes #3742.

Three fixes to what ng deploy generates for Cloud Functions:

  • DEFAULT_NODE_VERSION goes from 14 to 22.
    • Node 14 was decommissioned by Cloud Functions in early 2025, so the generated function could not deploy at all.
    • 22 is the newest runtime Cloud Functions supports.
    • It satisfies the engines ranges of @angular/core (^20.19.0 || ^22.12.0 || >=24.0.0) and firebase-admin (>=18).
    • Node 20 would also deploy today, but its security support ended 2026-04-30.
    • The same constant picks the Cloud Run base image, so that path moves from the stale node:14-slim to node:22-slim.
  • The gen 1 template requires firebase-functions/v1.
    • On firebase-functions 6 the v1 API moved off the package root, so the generated functions.region(...) call threw TypeError: functions.region is not a function on cold start.
    • The /v1 subpath is present on both firebase-functions 6 and 7.
  • The docs example asks for functionsNodeVersion: 22 instead of the decommissioned 12.

These defects also affect the v20 line and are planned for cherry-pick onto the 20.0.x release branch after this lands.

…rated Cloud Functions

The generated function declared engines.node 14, a runtime Cloud
Functions decommissioned in early 2025, so it could not deploy at all.
The gen 1 template also called functions.region() on the
firebase-functions package root, which moved to the /v1 subpath in v6,
so a deployed function crashed at cold start with
TypeError: functions.region is not a function.

Node 22 is the newest runtime Cloud Functions supports and satisfies
the engines ranges of @angular/core and firebase-admin. Node 20 would
deploy today, but its security support ended 2026-04-30. The same
constant picks the Cloud Run base image, now node:22-slim. The docs
example moves off the decommissioned functionsNodeVersion 12.
@armando-navarro armando-navarro added bump: patch comp: schematics ng add / deploy schematics (src/schematics). comp: ssr Server-side rendering, hydration, @angular/ssr interop. type: bug Defect: expected behavior doesn't happen. labels Aug 11, 2026

@tyler-reitz tyler-reitz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, approving. Three non-blocking notes.

site/src/get-started/deploying.md:107 still has the same example at "functionsNodeVersion": 12. Nothing in .github/workflows builds site/, so it's not a deploy risk, but it's the other half of the docs fix.

The new comment above require('firebase-functions/v1') sits inside the parameter list, between functionName and ) =>. Legal, but it scans as a parameter annotation. Above export const defaultFunction would read better.

On tests: asserting defaultFunction(...) contains firebase-functions/v1 goes red against the old template and green against this one (verified the substring both ways). Cheap insurance before the 20.0.x cherry-pick.

One claim I couldn't check: firebase-admin engines >=18, since the package isn't installed until #3745 lands. Inference on my side, worth confirming before the cherry-pick.

Confirmed the core fix locally against firebase-functions 6.5.0: require('firebase-functions').region is undefined, require('firebase-functions/v1').region is a function.

@tyler-reitz

Copy link
Copy Markdown
Collaborator

Correcting one thing from my review above: I flagged the firebase-admin engines >=18 claim as unverified. It checks out. firebase-admin 13.0.0 through 13.10.0 all declare node: ">=18", so Node 22 satisfies the whole ^13.0.0 range the manifest will pin once #3745 lands. Nothing to change here, and nothing to re-check before the 20.0.x cherry-pick.

The site/ copy of the deploy guide still showed the decommissioned 12,
flagged in review. Also fixes a spelling error on the same passage.
Add two specs for what the earlier commit in this PR fixed: the gen 1
template requires firebase-functions/v1, and the default runtime is 22.
Both specs fail when run against the old template. Also moves the /v1
comment above the export so it no longer reads like a parameter
annotation.
@armando-navarro

Copy link
Copy Markdown
Collaborator Author

Thanks for the careful pass, and for checking the v1 claim against a real install.

All 3 of your suggestions are implemented now:

  • The site/ copy of the example now says 22 as well, plus a spelling fix on the same passage.
  • The comment now sits above export const defaultFunction. I agree it reads better there.
  • I added a spec covering both things this PR changes: the gen 1 template requires firebase-functions/v1, and the default runtime is 22.

@armando-navarro
armando-navarro merged commit 0b8a49d into angular:main Aug 12, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bump: patch comp: schematics ng add / deploy schematics (src/schematics). comp: ssr Server-side rendering, hydration, @angular/ssr interop. type: bug Defect: expected behavior doesn't happen.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng deploy generates a Cloud Function that targets the decommissioned Node 14 runtime and crashes on firebase-functions 6

2 participants