[wrangler] Recover concurrent Preview name collisions #17072
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 398 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.358
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #17072"
general
weight: 0.35
NuroDev
Fixes #16464.
Summary
wrangler previewcurrently performsgetPreviewfollowed bycreatePreviewwhen the name is missing. Two builds for the same branch can both observe a missing Preview before either creates it. The secondPOSTthen fails with Cloudflare API error100338("a preview with name ... already exists"), even though it could continue by using the Preview that now exists.This change handles only
100338fromcreatePreview: it reads the named Preview again, treats it as an existing Preview, and applies the intended Preview settings before uploading its deployment. Other creation errors are propagated, and a failed second lookup is propagated. No Previews are deleted and no unbounded retry loop is introduced.It also includes a patch changeset for
@cloudflare/deploy-helpersandwrangler.Regression evidence
A deterministic mocked concurrent-build test holds both initial GET requests until both have observed a missing Preview, then causes one create request to return
100338. The test verifies that both deployments succeed, and that the late creator re-reads and updates the existing Preview. Two further tests verify a non-conflict creation error and a failed post-conflict read.Red/green: The new concurrency test fails with
100338on originalmain@56974d49141e72b19b33b74a19c160f734128108, then passes with this patch. All three changed Git blobs match the independently tested patch.Validated locally using Node.js 22.23.4 and pnpm 10.33.0:
pnpm --filter @cloudflare/deploy-helpers run test:ci: 366/366 tests, 32/32 files passed.pnpm --filter @cloudflare/deploy-helpers run check:type: passed.pnpm --filter @cloudflare/deploy-helpers run type:tests: passed.oxlint --deny-warnings --type-awareon the two changed TypeScript files: 0 warnings/errors.oxfmt --checkon all three changed files andgit diff --check: passed.Scope / uncertainty: No credentialed Cloudflare E2E deployment was run, and the HTTP status of the original reporter's first GET is unknown. This patch addresses the reproducible get-then-create conflict; it does not assert that unrelated Cloudflare API eventual-consistency problems have been fixed.
---
- [x] Tests included/updated
- [ ] Automated tests not possible - manual testing has been completed as follows:
- [ ] Additional testing not necessary because:
- [ ] Cloudflare docs PR(s):
- [x] Documentation not necessary because: this changes internal retry/recovery behavior without adding user-facing configuration; the changeset documents the bug fix.
<!-- devin-review-badge-begin -->
---
<a href="https://cloudflare.devinenterprise.com/review/cloudflare/workers-sdk/pull/17072" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->