Skip to content

fix(cloudflare): resolve vite plugin config once across call sites#16868

Merged
matthewp merged 4 commits into
withastro:mainfrom
helio-cf:refactor/cloudflare-centralize-vite-plugin
May 26, 2026
Merged

fix(cloudflare): resolve vite plugin config once across call sites#16868
matthewp merged 4 commits into
withastro:mainfrom
helio-cf:refactor/cloudflare-centralize-vite-plugin

Conversation

@helio-cf
Copy link
Copy Markdown
Contributor

@helio-cf helio-cf commented May 26, 2026

User options like remoteBindings, inspectorPort, persistState, configPath, and auxiliaryWorkers were silently dropped during astro preview because the preview entrypoint only received the adapter-computed half of the config.

Fixes #16867

Changes

  • Fixes user options passed to cloudflare({...}) (remoteBindings, inspectorPort, persistState, configPath, auxiliaryWorkers) being silently dropped during astro preview. The preview entrypoint was only receiving the adapter-computed half of the @cloudflare/vite-plugin config via globalThis.
  • Restructures the adapter to resolve the full @cloudflare/vite-plugin config exactly once at astro:config:setup time. All three call sites (dev/build plugin, prerenderer preview server, astro preview entrypoint) now spread a single pre-merged cfPluginConfig. The unmerged adapter-only half is a local const that goes out of scope, so no future call site can accidentally drop user options.
  • Same bug class as remoteBindings: false priority over wrangler settings inconsistent during build #16705 (fixed for the prerenderer in fix(cloudflare): respect remoteBindings during prerender build #16707). This closes the equivalent gap on the astro preview path and structurally prevents it from recurring.
  • Changeset included.

Testing

I've tested it with local npm patch, let me know if we have some e2e tests for these

Docs

No docs added, just a fix

User options like remoteBindings, inspectorPort, persistState, configPath,
and auxiliaryWorkers were silently dropped during astro preview because the
preview entrypoint only received the adapter-computed half of the config.
Resolve the full @cloudflare/vite-plugin config once at integration setup
time so every call site (dev/build, prerenderer, preview) spreads a single
merged object and cannot accidentally drop user options.
@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label May 26, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 26, 2026

🦋 Changeset detected

Latest commit: 62774cf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 37 packages
Name Type
@astrojs/cloudflare Patch
@test/astro-cloudflare-node-prerender-mdx Patch
@test/astro-cloudflare Patch
@test/astro-cloudflare-allowed-hosts Patch
@test/astro-cloudflare-astro-dev-platform Patch
@test/astro-cloudflare-astro-env Patch
@test/astro-cloudflare-binding-image-service Patch
@test/astro-cloudflare-cache-provider-wait-until Patch
@test/astro-cloudflare-client-address Patch
@test/astro-cloudflare-compile-image-service Patch
@test/astro-cloudflare-custom-entryfile Patch
@test/astro-cloudflare-dev-image-endpoint Patch
@test/astro-cloudflare-external-image-service Patch
@test/astro-cloudflare-external-redirects Patch
@test/astro-cloudflare-internal-redirects Patch
@test/astro-cloudflare-no-output Patch
@test/astro-cloudflare-prerender-node-env Patch
@test/astro-cloudflare-prerender-queue-consumers Patch
@test/astro-cloudflare-prerender-styles Patch
@test/astro-cloudflare-prerenderer-errors Patch
@test/routing-priority-cloudflare Patch
@test/cf-server-entry Patch
@test/astro-cloudflare-server-island-prerender-framework Patch
@test/astro-cloudflare-sessions Patch
@test/astro-cloudflare-sql-import Patch
@test/cf-ssr-deps Patch
@test/astro-cloudflare-static Patch
@test/astro-cloudflare-svelte-rune-deps Patch
@test/astro-cloudflare-top-level-return Patch
@test/cf-user-optimize-deps Patch
@test/astro-cloudflare-vite-plugin Patch
@test/astro-cloudflare-with-base Patch
@test/astro-cloudflare-with-react Patch
@test/astro-cloudflare-with-solid-js Patch
@test/astro-cloudflare-with-svelte Patch
@test/astro-cloudflare-with-vue Patch
@test/astro-cloudflare-wrangler-preview-platform Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

… preview

Verifies that astro preview honors remoteBindings: false when a wrangler
binding is flagged remote: true. Confirmed to fail before the fix in
b4946e2 — wrangler.maybeStartOrUpdateRemoteProxySession throws from the
@cloudflare/vite-plugin preview path because the option is dropped.
@helio-cf helio-cf force-pushed the refactor/cloudflare-centralize-vite-plugin branch from cc796bb to 7dea3a0 Compare May 26, 2026 16:35
@matthewp
Copy link
Copy Markdown
Contributor

Looks great, thanks!

@matthewp matthewp merged commit f9bae95 into withastro:main May 26, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Astro preview does not respect offline remotebindings configuration for cloudflare adapter

2 participants