You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Raising memory on an existing 2nd gen function keeps the old CPU, so deploys above 4GiB fail #11492
const{ onRequest }=require("firebase-functions/v2/https");exports.cpubugtest=onRequest({region: "us-central1",memory: "512MiB"},// no cpu set(req,res)=>res.send("ok"),);
[REQUIRED] Steps to reproduce
Deploy the function above with memory: "512MiB". It gets 1 CPU.
Change memory to "4GiB" and deploy again.
Change memory to "8GiB" and deploy again.
[REQUIRED] Expected behavior
When cpu isn't set, the CLI picks the CPU based on memory, the same as it does for a new function:
Memory
Existing function
New function
4GiB
2 CPU
2 CPU
8GiB
2 CPU, deploy works
2 CPU
[REQUIRED] Actual behavior
The function keeps its old CPU (1):
At 4GiB, the deploy works, but the function has 1 CPU instead of 2.
At 8GiB, the deploy fails:
HTTP Error: 400, Could not update Cloud Run service projects/<project>/locations/us-central1/services/cpubugtest. spec.template.spec.containers[0].resources.limits.memory: Invalid value specified for container memory. For 1.0 CPU, memory must be between 128Mi and 4Gi inclusive.
Cause: In src/deploy/functions/prepare.ts, if cpu isn't set, the CLI copies the CPU from the function that's already deployed:
Thanks for opening this report and for providing a clear repro along with your findings, @CorieW! I was able to reproduce the issue, and I think your observations are correct. Since the CLI copies the functions previously set cpu when it isn't explicitly provided, it will skip memoryToGen2Cpu in resolveCpuAndConcurrency which could lead to an invalid cpu value.
It looks like there is an open PR #11526, which is currently being reviewed, that addresses this behavior. While waiting for the fix to get merged, for anyone also encountering this issue, the workaround specified in the report should get you unblocked.
const{ onRequest }=require("firebase-functions/v2/https");exports.cpubugtest=onRequest({region: "us-central1",memory: "8GiB",cpu: 2// expicitly set cpu},(req,res)=>res.send("ok"),);
Activity
aalej commentedon Nov 16, 2026
Thanks for opening this report and for providing a clear repro along with your findings, @CorieW! I was able to reproduce the issue, and I think your observations are correct. Since the CLI copies the functions previously set cpu when it isn't explicitly provided, it will skip
memoryToGen2CpuinresolveCpuAndConcurrencywhich could lead to an invalid cpu value.It looks like there is an open PR #11526, which is currently being reviewed, that addresses this behavior. While waiting for the fix to get merged, for anyone also encountering this issue, the workaround specified in the report should get you unblocked.
Marking this as reproducible.
test(functions): add edge-case tests for cpu preservation and recalcu…