`wrangler pages deploy` does not say when a deploy went to Preview instead of Production

Aperta Adatta ai principianti
#17,159 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
git, nodejs, typescript
Ambito
cli, devtools

Direzione di ricerca

Il codice rilevante si trova in packages/wrangler/src/pages/deploy.ts, intorno al rilevamento del branch e all'output del deployment (righe collegate 574-581). Leggi come il branch viene ricavato da git rev-parse --abbrev-ref HEAD e dove viene stampato il risultato del deployment. Riproduci il caso eseguendo il deploy da un branch non di produzione e controlla nella voce pages-deploy-detailed dell'output i campi environment e production_branch. È completato quando un deployment di Preview stampa un messaggio che indica il branch di produzione e suggerisce --branch, con test che coprono questo output.

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

Descrizione

What versions & operating system are you using?

Wrangler 4.166.0, Node v24.19.0, Windows 11 (10.0.26300). The same code path is on main as of 2026-11-24 (wrangler 4.168.0).

Please provide a link to a minimal reproduction

https://github.com/cloudflare/workers-sdk/blob/0c06246f05e847da853b283448f7a760189a7c2a/packages/wrangler/src/pages/deploy.ts#L574-L581

Describe the Bug

When --branch is not passed, wrangler pages deploy takes the branch from git rev-parse --abbrev-ref HEAD, and Pages makes every branch other than the project's production branch a Preview. git init had given our repo a master branch while the Pages project's production branch was main, so every deploy was a Preview and production stopped updating. The output gave no hint. It looked like this (reconstructed from the current source; I no longer have the original log):

✨ Success! Uploaded <n> files (...)

🌎 Deploying...
✨ Deployment complete! Take a peek over at https://<hash>.<project>.pages.dev
✨ Deployment alias URL: https://master.<project>.pages.dev

Our production site stayed on an old version until we noticed by hand.

Steps to reproduce:

  1. A Pages project whose production branch is main.
  2. In a git checkout on any other branch (e.g. master), run wrangler pages deploy <dir> --project-name <project>.
  3. The deploy succeeds and prints "Deployment complete!", but it is a Preview; the production URL is unchanged.

Expected: the output says that this was a preview deployment and names the production branch, e.g. "This is a preview deployment for branch "master", so production was not updated. To deploy these assets to production, re-run with --branch=main (your production branch)."

The create-deployment response already carries environment and production_branch (Wrangler writes both into the pages-deploy-detailed output entry since #7252), so no extra API call is needed.

I have a small fix with tests ready and am happy to open a PR if that is welcome.

Found on my own Pages site. The report and the fix were prepared with help from Claude (Anthropic).

Please provide any relevant error logs

None: the deploy reports success.

Lingua principale
TypeScript
Stelle
4.7k
Fork
1.7k
Merge medio
1g 22h
PR unite (30g)
287

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 cloudflare/workers-sdk

Tutte le issue di cloudflare/workers-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.