-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
v6-beta: Error when running vitest with Cloudflare: "Avoid setting resolve.external in your Cloudflare Worker environments" #15310
Description
Astro Info
Astro v6.0.0-beta.3
Vite v7.3.1
Node v24.6.0
System macOS (arm64)
Package Manager pnpm
Output static
Adapter @astrojs/cloudflare (v13.0.0-beta.1)
Integrations @astrojs/react (v5.0.0-beta.2)
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I followed the upgrade guide to upgrade to v6 beta with Cloudflare, and most things have gone smoothly. I am able to run the dev server and launch my app just fine.
However, I have run into a blocker issue. When I run my tests, which was working fine with v5, I now get the following error:
vitest --browser.headless
09:15:25 [@astrojs/cloudflare] Enabling sessions with Cloudflare KV with the "KV" KV binding.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Startup Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: The following environment options are incompatible with the Cloudflare Vite plugin:
- "ssr" environment: `resolve.external`: ["_http_agent","_http_client","_http_common","_http_incoming","_http_outgoing","_http_server","_stream_duplex","_stream_passthrough","_stream_readable","_stream_transform","_stream_wrap","_stream_writable","_tls_common","_tls_wrap","assert","assert/strict","async_hooks","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","dns/promises","domain","events","fs","fs/promises","http","http2","https","inspector","inspector/promises","module","net","os","path","path/posix","path/win32","perf_hooks","process","punycode","querystring","readline","readline/promises","repl","stream","stream/consumers","stream/promises","stream/web","string_decoder","sys","timers","timers/promises","tls","trace_events","tty","url","util","util/types","v8","vm","wasi","worker_threads","zlib","node:sea","node:sqlite","node:test","node:test/reporters","node:_http_agent","node:_http_client","node:_http_common","node:_http_incoming","node:_http_outgoing","node:_http_server","node:_stream_duplex","node:_stream_passthrough","node:_stream_readable","node:_stream_transform","node:_stream_wrap","node:_stream_writable","node:_tls_common","node:_tls_wrap","node:assert","node:assert/strict","node:async_hooks","node:buffer","node:child_process","node:cluster","node:console","node:constants","node:crypto","node:dgram","node:diagnostics_channel","node:dns","node:dns/promises","node:domain","node:events","node:fs","node:fs/promises","node:http","node:http2","node:https","node:inspector","node:inspector/promises","node:module","node:net","node:os","node:path","node:path/posix","node:path/win32","node:perf_hooks","node:process","node:punycode","node:querystring","node:readline","node:readline/promises","node:repl","node:stream","node:stream/consumers","node:stream/promises","node:stream/web","node:string_decoder","node:sys","node:timers","node:timers/promises","node:tls","node:trace_events","node:tty","node:url","node:util","node:util/types","node:v8","node:vm","node:wasi","node:worker_threads","node:zlib","node:node:sea","node:node:sqlite","node:node:test","node:node:test/reporters"]
To resolve this issue, avoid setting `resolve.external` in your Cloudflare Worker environments.
at validateWorkerEnvironmentOptions (file:///<snip>/project-dir/node_modules/.pnpm/@cloudflare+vite-plugin@1.21.2_vite@7.3.1_@types+node@25.0.10_jiti@2.6.1_lightningcss@1_c8117fd9c7311a4addbd315380d1c09a/node_modules/@cloudflare/vite-plugin/dist/index.mjs:21799:9)
at BasicMinimalPluginContext.configResolved (file:///<snip>/project-dir/node_modules/.pnpm/@cloudflare+vite-plugin@1.21.2_vite@7.3.1_@types+node@25.0.10_jiti@2.6.1_lightningcss@1_c8117fd9c7311a4addbd315380d1c09a/node_modules/@cloudflare/vite-plugin/dist/index.mjs:21835:53)
at file:///<snip>/project-dir/node_modules/.pnpm/vite@7.3.1_@types+node@25.0.10_jiti@2.6.1_lightningcss@1.30.2_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:35675:87
at Array.map (<anonymous>)
at resolveConfig (file:///<snip>/project-dir/node_modules/.pnpm/vite@7.3.1_@types+node@25.0.10_jiti@2.6.1_lightningcss@1.30.2_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:35675:68)
at async _createServer (file:///<snip>/project-dir/node_modules/.pnpm/vite@7.3.1_@types+node@25.0.10_jiti@2.6.1_lightningcss@1.30.2_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:25362:67)
at async createViteServer (file:///<snip>/project-dir/node_modules/.pnpm/vitest@4.0.18_@types+node@25.0.10_@vitest+browser-playwright@4.0.18_jiti@2.6.1_lightningcss@1.30.2_yaml@2.8.2/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:9870:17)
at async createVitest (file:///<snip>/project-dir/node_modules/.pnpm/vitest@4.0.18_@types+node@25.0.10_@vitest+browser-playwright@4.0.18_jiti@2.6.1_lightningcss@1.30.2_yaml@2.8.2/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:13186:17)
at async prepareVitest (file:///<snip>/project-dir/node_modules/.pnpm/vitest@4.0.18_@types+node@25.0.10_@vitest+browser-playwright@4.0.18_jiti@2.6.1_lightningcss@1.30.2_yaml@2.8.2/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:13548:14)
at async startVitest (file:///<snip>/project-dir/node_modules/.pnpm/vitest@4.0.18_@types+node@25.0.10_@vitest+browser-playwright@4.0.18_jiti@2.6.1_lightningcss@1.30.2_yaml@2.8.2/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:13494:14)
If there is a migration guide to migrate tests using vitest to v6 + wrangler, I couldn't find it.
The following is my astro.config.mjs
// @ts-check
import cloudflare from "@astrojs/cloudflare";
import react from "@astrojs/react";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "astro/config";
// https://astro.build/config
export default defineConfig({
adapter: cloudflare({
sessionKVBindingName: "KV",
imageService: "cloudflare",
}),
vite: {
plugins: [
tailwindcss(),
],
},
integrations: [
react({
babel: {
plugins: ["babel-plugin-react-compiler"],
},
}),
],
});So, it's a fairly vanilla config using cloudflare, react and tailwind.
The following is my vitest.config.ts:
/// <reference types="vitest/config" />
import { playwright } from "@vitest/browser-playwright";
import { getViteConfig } from "astro/config";
export default getViteConfig({
test: {
browser: {
provider: playwright(),
enabled: true,
instances: [{ browser: "chromium" }],
screenshotFailures: false,
},
teardownTimeout: 500,
},
});This uses playwright to execute tests. Ideally, I would want the tests to run in wrangler, so that I can test in an environment that resembles production as closely as possible.
With this exact configuration, this is working fine with astro v5.x. It's the upgrade to v6-beta that has broken the tests.
Is this something I'm doing wrong? Any idea what I can do to fix it?
What's the expected result?
I would have expected the tests to run with v6, just as it did with v5.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ghgbrlkg Not working due to stackblitz not able to upgrade to v6-beta
❯ npx @astrojs/upgrade beta
Need to install the following packages:
@astrojs/upgrade@0.6.2
Ok to proceed? (y)
astro Integration upgrade aborted.
▲ error Version beta could not be found!
◼ check https://github.com/withastro/astro/releases
Participation
- I am willing to submit a pull request for this issue.