-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
Recommend nodejs_compat flag instead of putting it in the troubleshooting section. Related:
Svelte error: async_local_storage_unavailable
The node API `AsyncLocalStorage` is not available, but is required to use async server rendering.
https://svelte.dev/e/async_local_storage_unavailable
Guide users to set the compatibility_date to the current date. Reference
When you start your project, you should always set
compatibility_dateto the current date.
Add a wrangler.jsonc example for the Cloudflare Pages section.
This helps adding the nodejs_compat flag A LOT easier.
- assets # reserved for Workers only
+ pages_build_output_dir # requiredThe name 'ASSETS' is reserved in Pages projects. Please use a different name for your Assets binding.
A wrangler.toml file was found but it does not appear to be valid. Did you mean to use wrangler.toml to configure Pages? If so, then make sure the file is valid and contains the
pages_build_output_dirproperty. Skipping file and continuing.
{
"name": "svelte-kit-cloudflare",
"pages_build_output_dir": ".svelte-kit/cloudflare", // required
"compatibility_flags": ["nodejs_compat"], // easier to add
"compatibility_date": "2025-12-12" // easier to add
}Remove trailing comma from the wrangler.jsonc example
It does work in Workers but causes parse error in Pages. Related:
wrangler.jsoncfile not utilized in Cloudflare Pages build #14926 (comment)- Tolerate trailing commas in jsonc format microsoft/vscode#102061
{
"name": "<any-name-you-want>",
"main": ".svelte-kit/cloudflare/_worker.js",
"compatibility_date": "2025-01-01",
"assets": {
"binding": "ASSETS",
"directory": ".svelte-kit/cloudflare", // causes parse error in the Pages build system
}
}Add the $schema field in wrangler.jsonc. Requires wrangler installation, but it provides type safety.
{
"$schema": "./node_modules/wrangler/config-schema.json", // AddedReproduction
https://github.com/hyunbinseo/svelte-kit-cloudflare
Logs
System Info
System:
OS: Windows 11 10.0.26200
CPU: (8) x64 Intel(R) Core(TM) Ultra 7 258V
Memory: 9.67 GB / 31.48 GB
Binaries:
Node: 24.12.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\11728_1765560385450\node.EXE
npm: 11.6.2 - C:\Users\hyunb\AppData\Local\fnm_multishells\11728_1765560385450\npm.CMD
pnpm: 10.25.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\11728_1765560385450\pnpm.CMD
Deno: 2.4.0 - C:\Users\hyunb\.deno\bin\deno.EXE
Browsers:
Chrome: 143.0.7499.109
Edge: Chromium (140.0.3485.54)
Firefox: 146.0 - C:\Program Files\Mozilla Firefox\firefox.exe
npmPackages:
@sveltejs/adapter-cloudflare: ^7.2.4 => 7.2.4
@sveltejs/kit: ^2.49.2 => 2.49.2
@sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1
svelte: ^5.45.10 => 5.45.10
vite: ^7.2.7 => 7.2.7Severity
annoyance
Additional Information
It would be nice if the sv CLI added wrangler.jsonc during scaffolding.
Choosing the cloudflare adapter basically means CF Workers or Pages deployment.
◇ What would you like to add to your project? (use arrow keys / space bar)
│ sveltekit-adapter
│
◇ Which SvelteKit adapter would you like to use?
│ cloudflare
Could this be achieved? @jycouet
- Install
@sveltejs/adapter-cloudflareandwrangleras well - Create a
wrangler.jsoncfile with the$schemafield set - Include
nodejs_compatflag and set the date to the date of scaffolding
{ "name": "<any-name-you-want>", "main": ".svelte-kit/cloudflare/_worker.js", "compatibility_date": "2025-01-01", // almost an year has passed "assets": { "binding": "ASSETS", "directory": ".svelte-kit/cloudflare", } }