Raising memory on an existing 2nd gen function keeps the old CPU, so deploys above 4GiB fail

Aperta Adatta ai principianti
#11,492 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@anjalimishra-0007 ci sta già lavorando.

Dal 16/11/2026.

  • #11526 di @anjalimishra-0007 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
google-cloud, node.js, typescript
Ambito
backend, cloud

Direzione di ricerca

Inizia in src/deploy/functions/prepare.ts, nella logica di copia della CPU descritta nell’issue, quindi segui come resolveCpuAndConcurrency gestisce la memoria quando cpu non è impostato. Confronta il comportamento di aggiornamento con quello di una nuova funzione per i casi da 4GiB e 8GiB. Il lavoro è completato quando i deployments scelgono la CPU prevista in base alla memoria e l’aggiornamento segnalato con 8GiB riesce.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

api: functions reproducible type: bug
[REQUIRED] Environment info

firebase-tools: 15.34.0

Platform: Linux

[REQUIRED] Test case
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
  1. Deploy the function above with memory: "512MiB". It gets 1 CPU.
  2. Change memory to "4GiB" and deploy again.
  3. 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:

if (typeof wantE.cpu === "undefined" && haveE.cpu) {
  wantE.cpu = haveE.cpu;
}

Because cpu now has a value, resolveCpuAndConcurrency doesn't pick a CPU based on memory, and the old CPU is sent in the update.

Workaround: Set cpu yourself (for example cpu: 2).

Lingua principale
TypeScript
Stelle
4.5k
Fork
1.3k
Merge medio
3g 9h
PR unite (30g)
99

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di firebase/firebase-tools

Tutte le issue di firebase/firebase-tools

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.