Skip to content

Commit 408e564

Browse files
fix(deploy): target Node 22 and the firebase-functions/v1 API in generated 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.
1 parent 279d891 commit 408e564

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

docs/deploy/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Setting `functionsNodeVersion` and `functionsRuntimeOptions` in your `angular.js
9797
"deploy": {
9898
"builder": "@angular/fire:deploy",
9999
"options": {
100-
"functionsNodeVersion": 12,
100+
"functionsNodeVersion": 22,
101101
"functionsRuntimeOptions": {
102102
"memory": "2GB",
103103
"timeoutSeconds": 10,

src/schematics/deploy/functions-templates.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { DeployBuilderOptions } from './actions';
22

3-
export const DEFAULT_NODE_VERSION = 14;
3+
// Must be a runtime Cloud Functions still accepts, and must satisfy the engines of @angular/core
4+
// (the function runs the Angular server) and of firebase-admin. The `dockerfile` template below
5+
// also drops it into `FROM node:<version>-slim`, so it picks the base image on the Cloud Run path.
6+
export const DEFAULT_NODE_VERSION = 22;
47
export const DEFAULT_FUNCTION_NAME = 'ssr';
58

69
const DEFAULT_FUNCTION_REGION = 'us-central1';
@@ -34,7 +37,9 @@ export const defaultFunction = (
3437
path: string,
3538
options: DeployBuilderOptions,
3639
functionName: string|undefined,
37-
) => `const functions = require('firebase-functions');
40+
// `.region()` lives on the /v1 subpath since firebase-functions 6. Requiring the package root
41+
// instead still resolves, and fails only when the deployed function serves its first request.
42+
) => `const functions = require('firebase-functions/v1');
3843
3944
// Increase readability in Cloud Logging
4045
require("firebase-functions/logger/compat");

0 commit comments

Comments
 (0)