← Back to Pull requests

[wrangler] Recover concurrent Preview name collisions #17072

Closed
unknown closed this pull request without merging on Nov 20, 2026 16:37 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 06:59 UTC
Author

Fixes #16464.

Summary

wrangler preview currently performs getPreview followed by createPreview when the name is missing. Two builds for the same branch can both observe a missing Preview before either creates it. The second POST then fails with Cloudflare API error 100338 ("a preview with name ... already exists"), even though it could continue by using the Preview that now exists.

This change handles only 100338 from createPreview: 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-helpers and wrangler.

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 100338 on original main@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-aware on the two changed TypeScript files: 0 warnings/errors.

  • oxfmt --check on all three changed files and git 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.

    ---

  • Tests

  • - [x] Tests included/updated
    - [ ] Automated tests not possible - manual testing has been completed as follows:
    - [ ] Additional testing not necessary because:
  • Public documentation

  • - [ ] 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.

    [!NOTE]

    This is an AI-assisted contribution prepared by ChatGPT (GPT-6) and submitted with the GitHub account owner's authorization.

    <!-- 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 -->

    Diff: 398 lines (+298 / -100) across 4 files Reviewer: NuroDev Review duration: 578m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.2% (MEDIUM) · Higher = larger blast radius
    43.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.1% · Safe to merge
    17.1%