Astro Info
Astro v6.0.0-beta.7
Node v24.6.0
System macOS (arm64)
Package Manager pnpm
Output static
Adapter @astrojs/cloudflare
Integrations @astrojs/react
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When trying to build my Astro 6-beta project which uses Cloudflare workers, I get the following error at the end of the build when prerendering:
<snip>
11:15:50 [types] Generated 3.60s
11:15:50 [build] output: "static"
11:15:50 [build] mode: "server"
11:15:50 [build] directory: /<snip>/<project-dir>/dist/
11:15:50 [build] adapter: @astrojs/cloudflare
11:15:50 [build] Collecting build info...
11:15:50 [build] ✓ Completed in 3.64s.
11:15:50 [build] Building server entrypoints...
Using vars defined in .env
11:15:51 [vite] ✓ built in 1.66s
11:15:52 [vite] ✓ built in 609ms
11:15:55 [vite] ✓ built in 3.00s
11:15:55 [build] ✓ Completed in 5.31s.
prerendering static routes
11:15:55 ▶ src/pages/index.astro
11:15:55 └─ /index.html11:15:55 [ERROR] Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'cloudflare:'
at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:183:11)
at defaultLoad (node:internal/modules/esm/load:78:3)
at nextLoad (node:internal/modules/esm/hooks:748:28)
at Hooks.load (node:internal/modules/esm/hooks:385:26)
at handleMessage (node:internal/modules/esm/worker:201:24)
at checkForMessages (node:internal/modules/esm/worker:143:28)
at process.<anonymous> (node:internal/modules/esm/worker:162:5)
at process.emit (node:events:508:28)
11:15:55 [ERROR] [build] Caught error rendering /: Error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'cloudflare:'
Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'cloudflare:'
Stack trace:
at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:183:11)
at nextLoad (node:internal/modules/esm/hooks:748:28)
at handleMessage (node:internal/modules/esm/worker:201:24)
at process.<anonymous> (node:internal/modules/esm/worker:162:5)
ELIFECYCLE Command failed with exit code 1.
I am indeed using import { env } from "cloudflare:workers"; in my code.
My astro config is as follows:
export default defineConfig({
adapter: cloudflare({
imageService: "cloudflare",
}),
// ...
I don't think the imageService has any bearing on this error, but otherwise it's just a vanilla astro config using the cloudflare adapter.
In trying to create a minimal reproduction of the error, I ran into a similar but different error - this time, the dev server itself throws an error saying:
astro v6.0.0-beta.6 ready in 1187 ms
┃ Local http://localhost:4321/
┃ Network use --host to expose
▶ This is a beta prerelease build!
Report issues here: https://astro.build/issues
11:18:33 watching for file changes...
11:18:36 [ERROR] Could not import `cloudflare:workers`.
Hint:
This is often caused by a typo in the import path. Please make sure the file exists.
Error reference:
https://docs.astro.build/en/reference/errors/failed-to-load-module-ssr/
Stack trace:
at /<snip>/astro-6-cf-build/src/pages/index.astro:4:21
[...] See full stack trace in the browser, or rerun with --verbose.
What's the expected result?
importing "cloudflare:workers" should work
Link to Minimal Reproducible Example
https://github.com/rakeshpai/astro-6-cf-build
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When trying to build my Astro 6-beta project which uses Cloudflare workers, I get the following error at the end of the build when prerendering:
I am indeed using
import { env } from "cloudflare:workers";in my code.My astro config is as follows:
I don't think the
imageServicehas any bearing on this error, but otherwise it's just a vanilla astro config using the cloudflare adapter.In trying to create a minimal reproduction of the error, I ran into a similar but different error - this time, the dev server itself throws an error saying:
What's the expected result?
importing "cloudflare:workers" should work
Link to Minimal Reproducible Example
https://github.com/rakeshpai/astro-6-cf-build
Participation