Skip to content

[v6]: Error when running vitest with Cloudflare: "Avoid setting resolve.external in your Cloudflare Worker #15878

@rakeshpai

Description

@rakeshpai

Astro Info

Astro                    v6.0.3
Node                     v24.6.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  @astrojs/cloudflare
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I had previously created this as #15310 but that got closed seemingly in error, hence recreating.

When using Astro with Vitest and wrangler / Cloudflare, I get the following 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:///Users/rakeshpai/code/github/rakeshpai/astro-6-vite-error/node_modules/.pnpm/@cloudflare+vite-plugin@1.27.0_vite@7.3.1_@types+node@25.3.0__workerd@1.20260310.1_wrangler@4.72.0/node_modules/@cloudflare/vite-plugin/dist/index.mjs:21826:9)
    at BasicMinimalPluginContext.configResolved (file:///Users/rakeshpai/code/github/rakeshpai/astro-6-vite-error/node_modules/.pnpm/@cloudflare+vite-plugin@1.27.0_vite@7.3.1_@types+node@25.3.0__workerd@1.20260310.1_wrangler@4.72.0/node_modules/@cloudflare/vite-plugin/dist/index.mjs:21862:53)
    at file:///Users/rakeshpai/code/github/rakeshpai/astro-6-vite-error/node_modules/.pnpm/vite@7.3.1_@types+node@25.3.0/node_modules/vite/dist/node/chunks/config.js:35675:87
    at Array.map (<anonymous>)
    at resolveConfig (file:///Users/rakeshpai/code/github/rakeshpai/astro-6-vite-error/node_modules/.pnpm/vite@7.3.1_@types+node@25.3.0/node_modules/vite/dist/node/chunks/config.js:35675:68)
    at async _createServer (file:///Users/rakeshpai/code/github/rakeshpai/astro-6-vite-error/node_modules/.pnpm/vite@7.3.1_@types+node@25.3.0/node_modules/vite/dist/node/chunks/config.js:25362:67)
    at async createViteServer (file:///Users/rakeshpai/code/github/rakeshpai/astro-6-vite-error/node_modules/.pnpm/vitest@4.1.0_@edge-runtime+vm@5.0.0_@types+node@25.3.0_@vitest+browser-playwright@4.1.0_vite@7.3.1_@types+node@25.3.0_/node_modules/vitest/dist/chunks/cli-api.DuT9iuvY.js:8825:17)
    at async createVitest (file:///Users/rakeshpai/code/github/rakeshpai/astro-6-vite-error/node_modules/.pnpm/vitest@4.1.0_@edge-runtime+vm@5.0.0_@types+node@25.3.0_@vitest+browser-playwright@4.1.0_vite@7.3.1_@types+node@25.3.0_/node_modules/vitest/dist/chunks/cli-api.DuT9iuvY.js:14047:18)
    at async prepareVitest (file:///Users/rakeshpai/code/github/rakeshpai/astro-6-vite-error/node_modules/.pnpm/vitest@4.1.0_@edge-runtime+vm@5.0.0_@types+node@25.3.0_@vitest+browser-playwright@4.1.0_vite@7.3.1_@types+node@25.3.0_/node_modules/vitest/dist/chunks/cli-api.DuT9iuvY.js:14414:14)
    at async startVitest (file:///Users/rakeshpai/code/github/rakeshpai/astro-6-vite-error/node_modules/.pnpm/vitest@4.1.0_@edge-runtime+vm@5.0.0_@types+node@25.3.0_@vitest+browser-playwright@4.1.0_vite@7.3.1_@types+node@25.3.0_/node_modules/vitest/dist/chunks/cli-api.DuT9iuvY.js:14357:14)

Original issue was with v6-beta, but I've now updated the example repro to v6.

Run pnpm test in the example repo.

What's the expected result?

No error

Link to Minimal Reproducible Example

https://github.com/rakeshpai/astro-6-vite-error

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: cloudflareRelated to the Cloudflare adapter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions