Skip to content

fix(cloudflare): reconcile Worker preview subdomain state#285

Open
Dawsson wants to merge 2 commits into
alchemy-run:mainfrom
Dawsson:codex/reconcile-worker-preview-subdomain
Open

fix(cloudflare): reconcile Worker preview subdomain state#285
Dawsson wants to merge 2 commits into
alchemy-run:mainfrom
Dawsson:codex/reconcile-worker-preview-subdomain

Conversation

@Dawsson
Copy link
Copy Markdown
Contributor

@Dawsson Dawsson commented May 8, 2026

Issue

Cloudflare Worker reconciliation enabled Preview URLs when it called the subdomain API, but it only diffed the observed enabled flag. If a Worker had enabled: true and previewsEnabled: false, Alchemy skipped reconciliation.

This matters for the Cloudflare state store bootstrap because it reads the auth secret through an edge-preview request. Cloudflare documents Preview URLs as a separate Worker setting, and the script subdomain API exposes previews_enabled separately from enabled.

Docs:

Solution

  • Compare previewsEnabled when the desired workers.dev subdomain is enabled.
  • Keep the disabled case scoped to enabled, matching the existing API call that sends only enabled: false.
  • Retry the state-store secret probe for Cloudflare preview configuration errors (1031 / Invalid Workers Preview configuration) while preview routing propagates.

Validation

  • node_modules/.bin/oxfmt packages/alchemy/src/Cloudflare/Workers/Worker.ts packages/alchemy/src/Cloudflare/StateStore/State.ts
  • node_modules/.bin/tsc -b packages/alchemy/tsconfig.json --pretty false
  • git diff --check

I also tried a live Worker regression test that manually disabled Preview URLs and redeployed, but it timed out waiting for initial workers.dev subdomain propagation before reaching the preview assertion. I left that test out because it would be flaky.

@Dawsson Dawsson marked this pull request as ready for review May 8, 2026 07:13
@sam-goodwin
Copy link
Copy Markdown
Contributor

Please add regression tests

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.

2 participants