Skip to content

fix(cloud): stop PR preview builds failing on DO migrations (10211)#1194

Closed
RhysSullivan wants to merge 2 commits into
mainfrom
fix-cloud-orphan-and-pr-build
Closed

fix(cloud): stop PR preview builds failing on DO migrations (10211)#1194
RhysSullivan wants to merge 2 commits into
mainfrom
fix-cloud-orphan-and-pr-build

Conversation

@RhysSullivan

@RhysSullivan RhysSullivan commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Problem

Preview (non-main) Workers Builds deploy via wrangler versions upload, which rejects any config containing a Durable Object migration with error 10211 ("migrations must be applied via a non-versioned deployment"). Since apps/cloud's wrangler.jsonc carries the DO migration ledger (v1/v2), every PR's preview build fails.

Fix

build.mjs strips migrations from the generated dist/server/wrangler.json only on non-main CI branches (WORKERS_CI=1 + WORKERS_CI_BRANCH !== "main"). Previews share production's already-applied DO state, so they don't need (and can't apply) migrations. main keeps migrations and applies them on the real, non-versioned deploy.

Fail-safe by construction: it only ever strips on a confirmed non-main CI branch, so it can't drop migrations from a production deploy. Confirmed via the CF build log that the strip takes effect (the earlier error moved from 10211 to a different one once stripped).

Scope note

This intentionally does not delete the orphaned KV McpSessionDO class. That class is unbound and harmless, the migration ledger must stay regardless, and a delete-class PR's own preview build can't pass anyway. Left as-is with its one-line stub export.

Verified locally

  • typecheck 0, lint clean
  • normal/main build keeps migrations; preview-branch build logs the strip and emits no migrations in the deploy config

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 243e6c0 Commit Preview URL

Branch Preview URL
Jun 28 2026, 11:10 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 243e6c0 Jun 28 2026, 11:11 PM

@greptile-apps

greptile-apps Bot commented Jun 28, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes PR preview builds failing with Cloudflare error 10211 by post-processing the generated wrangler.json to strip the migrations field when running on a non-main CI branch. The guard is tight: the strip only fires when WORKERS_CI=1 is set AND the branch is confirmed to not be main, ensuring production deploys always retain their migrations.

  • Migration stripping logic: After the Vite build completes, build.mjs reads dist/server/wrangler.json and deletes cfg.migrations only for non-main CI branches, writing the patched config back before wrangler versions upload runs.
  • Fail-safe design: The condition requires both WORKERS_CI=1 and an explicit non-main branch name, so any misconfigured or local build leaves migrations intact.

Confidence Score: 5/5

Safe to merge: the change only affects preview CI builds, and the conditions prevent it from ever touching a production deploy.

The strip logic is gated behind two independent env-var checks (WORKERS_CI and WORKERS_CI_BRANCH !== 'main'), so the production deploy path is structurally unaffected. The file is a build artifact read and written in the same script, no shared state is mutated, and the branch is a single self-contained addition after all build steps have already succeeded.

No files require special attention.

Important Files Changed

Filename Overview
apps/cloud/scripts/build.mjs Adds a post-build step that strips migrations from the generated dist/server/wrangler.json on non-main CI preview branches, preventing Cloudflare error 10211 on wrangler versions upload.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[build.mjs starts] --> B[Run vite build steps]
    B --> C{build steps all exit 0?}
    C -- No --> D[process.exit]
    C -- Yes --> E{WORKERS_CI === '1' AND\nWORKERS_CI_BRANCH set?}
    E -- No --> F[Done: wrangler.json untouched]
    E -- Yes --> G{WORKERS_CI_BRANCH === 'main'?}
    G -- Yes/production --> F
    G -- No/preview branch --> H[Read dist/server/wrangler.json]
    H --> I{cfg.migrations\nnon-empty array?}
    I -- No --> J[Done: nothing to strip]
    I -- Yes --> K[delete cfg.migrations]
    K --> L[writeFileSync wrangler.json]
    L --> M[Log strip message]
    M --> N[Done: preview config has no migrations]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[build.mjs starts] --> B[Run vite build steps]
    B --> C{build steps all exit 0?}
    C -- No --> D[process.exit]
    C -- Yes --> E{WORKERS_CI === '1' AND\nWORKERS_CI_BRANCH set?}
    E -- No --> F[Done: wrangler.json untouched]
    E -- Yes --> G{WORKERS_CI_BRANCH === 'main'?}
    G -- Yes/production --> F
    G -- No/preview branch --> H[Read dist/server/wrangler.json]
    H --> I{cfg.migrations\nnon-empty array?}
    I -- No --> J[Done: nothing to strip]
    I -- Yes --> K[delete cfg.migrations]
    K --> L[writeFileSync wrangler.json]
    L --> M[Log strip message]
    M --> N[Done: preview config has no migrations]
Loading

Reviews (3): Last reviewed commit: "chore(cloud): suppress no-json-parse on ..." | Re-trigger Greptile

Comment thread apps/cloud/scripts/build.mjs
const cfg = JSON.parse(readFileSync(cfgUrl, "utf8"));
if (Array.isArray(cfg.migrations) && cfg.migrations.length > 0) {
delete cfg.migrations;
writeFileSync(cfgUrl, JSON.stringify(cfg));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 writeFileSync is called without JSON.stringify's space argument, so the patched wrangler.json is written as a single minified line with no trailing newline. This is a build artifact so it doesn't affect correctness, but if anything downstream ever logs or diffs the file it will be harder to read. Passing 2 as the space argument preserves the same formatting style used elsewhere in the repo.

Suggested change
writeFileSync(cfgUrl, JSON.stringify(cfg));
writeFileSync(cfgUrl, JSON.stringify(cfg, null, 2) + "\n");

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Jun 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1194

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1194

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1194

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1194

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1194

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1194

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1194

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1194

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1194

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1194

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1194

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1194

executor

npm i https://pkg.pr.new/executor@1194

commit: 97a3a1b

…ds stop failing

Preview (non-main) Workers Builds deploy via 'wrangler versions upload', which
rejects any config containing Durable Object migrations (error 10211). Previews
share production's already-applied DO state, so they neither need nor can apply
migrations. build.mjs strips 'migrations' from the generated dist/server/wrangler.json
on non-main CI branches; main keeps them and applies on the real deploy. Fail-safe:
only strips on a confirmed non-main CI branch, never on a production deploy.

Leaves the orphaned KV McpSessionDO + its stub export in place (harmless, unbound);
not worth a delete migration whose own preview build can't pass.
@RhysSullivan RhysSullivan changed the title chore(cloud): delete orphaned KV DO + stop PR builds failing on DO migrations fix(cloud): stop PR preview builds failing on DO migrations (10211) Jun 28, 2026
@RhysSullivan RhysSullivan force-pushed the fix-cloud-orphan-and-pr-build branch from 02518dd to 97a3a1b Compare June 28, 2026 23:04
@RhysSullivan

Copy link
Copy Markdown
Owner Author

Closing — unnecessary. Confirmed normal PRs already pass the executor-cloud preview build (only PRs that add a new DO migration hit 10211, which is rare and self-resolved now that the SQLite migration is applied). Not worth a permanent build-script workaround.

@RhysSullivan RhysSullivan deleted the fix-cloud-orphan-and-pr-build branch June 28, 2026 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant