From ea1171a25fc7a9c81a77cefcfcd99e53d43672a7 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 13 Nov 2026 19:34:13 +0000 Subject: [PATCH 1/2] fix(web): don't upload source maps with the Worker A real `wrangler deploy` uploads the bundle's source maps unless the config says otherwise; apps/web's are about 85 MB, above Cloudflare's 60 MiB limit (error 10021). A dry run does not check it. Documented in "Shrink the Worker" and the troubleshooting table. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CnAiFZHQw1SaeJbt11brzs --- .../content/docs/dev/deployments/cloud/cloudflare.mdx | 4 +++- apps/web/wrangler.jsonc | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/web/content/docs/dev/deployments/cloud/cloudflare.mdx b/apps/web/content/docs/dev/deployments/cloud/cloudflare.mdx index 122a63b4c..46ec467d7 100644 --- a/apps/web/content/docs/dev/deployments/cloud/cloudflare.mdx +++ b/apps/web/content/docs/dev/deployments/cloud/cloudflare.mdx @@ -205,9 +205,10 @@ By default Wrangler uploads every module the build wrote, including chunks nothi "no_bundle": false, "minify": true, "keep_names": false, +"upload_source_maps": false, ``` -The VitNode website went from 13.1 MiB to 6.6 MiB gzipped. Keep `keep_names` off: some server code sends functions to the browser as source text (the theme and scroll restoration scripts), and esbuild's name-keeping helper turns them into calls to a function the browser does not have, so every page the Worker renders fails with `n is not defined`. +The VitNode website went from 13.1 MiB to 6.6 MiB gzipped. Keep `keep_names` off: some server code sends functions to the browser as source text (the theme and scroll restoration scripts), and esbuild's name-keeping helper turns them into calls to a function the browser does not have, so every page the Worker renders fails with `n is not defined`. Turn `upload_source_maps` off too: a real deploy uploads the bundle's source maps unless told not to, and a large app's maps pass Cloudflare's 60 MiB limit (error `10021`), which a dry run does not check. If the app prerenders pages, also set `"assets": { "html_handling": "drop-trailing-slash" }`. A prerendered page is written as `page/index.html`, and Cloudflare otherwise redirects `/page` to `/page/`. @@ -223,6 +224,7 @@ With `npx wrangler dev` running, `http://localhost:8787/api/health/ready` answer | A Worker-rendered page fails with `n is not defined` in the browser | The Worker is minified with `keep_names` on. Set `"keep_names": false`. | | `CONNECTION_CLOSED` or `Cannot perform I/O on behalf of a different request` from the database | The client was created once at module load. Use `scopedDatabase`. | | Image uploads fail with "The image optimization library (sharp) failed to load" | Remove `storage.image` from the Worker's API config. | +| Deploy fails with `total sourcemap size is too large` (code `10021`) | Set `"upload_source_maps": false` in `wrangler.jsonc`. | | Deploy fails because the script is too large | [Shrink the Worker](#shrink-the-worker), and check that you are on Workers Paid. | ## Related diff --git a/apps/web/wrangler.jsonc b/apps/web/wrangler.jsonc index 5eef154ca..2eccef531 100644 --- a/apps/web/wrangler.jsonc +++ b/apps/web/wrangler.jsonc @@ -13,19 +13,21 @@ // Server code that ships functions to the browser as source (the theme and // scroll scripts) breaks under esbuild's name-keeping helper once minified. "keep_names": false, + // The bundle's source maps are about 85 MB, above Cloudflare's 60 MiB limit. + "upload_source_maps": false, // Prerendered pages are `page/index.html`: serve them at `/page`, as Node // does, instead of redirecting to `/page/`. "assets": { "html_handling": "drop-trailing-slash" }, "durable_objects": { "bindings": [ // The realtime hub that owns every WebSocket. The binding name is fixed. - { "name": "VITNODE_REALTIME", "class_name": "VitNodeRealtimeHub" } - ] + { "name": "VITNODE_REALTIME", "class_name": "VitNodeRealtimeHub" }, + ], }, // SQLite-backed, so the hub keeps its rooms while it hibernates. "migrations": [{ "tag": "v1", "new_sqlite_classes": ["VitNodeRealtimeHub"] }], "vars": { - "VITNODE_INSTALLATION_ID": "default" + "VITNODE_INSTALLATION_ID": "default", }, - "observability": { "enabled": true } + "observability": { "enabled": true }, } From 7a5962676cf9329d46ce70f376a2caf488ee5002 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 13 Nov 2026 19:49:43 +0000 Subject: [PATCH 2/2] fix(web): keep wrangler.jsonc free of trailing commas oxfmt (`trailingComma: "all"`) rewrote apps/web/wrangler.jsonc with trailing commas, and the build's config parser rejects them ("is not valid JSON"), failing `pnpm build:cloudflare`. Remove them and keep oxfmt off `wrangler.jsonc` in both the root and apps/web configs. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CnAiFZHQw1SaeJbt11brzs --- apps/web/.oxfmtrc.json | 3 ++- apps/web/wrangler.jsonc | 8 ++++---- oxfmt.config.mts | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/web/.oxfmtrc.json b/apps/web/.oxfmtrc.json index 7dacf39bf..c6ee6393a 100644 --- a/apps/web/.oxfmtrc.json +++ b/apps/web/.oxfmtrc.json @@ -13,6 +13,7 @@ "**/.vercel", "**/.turbo", "**/*.gen.ts", - "**/*.gen.d.ts" + "**/*.gen.d.ts", + "wrangler.jsonc" ] } diff --git a/apps/web/wrangler.jsonc b/apps/web/wrangler.jsonc index 2eccef531..cfa1a9498 100644 --- a/apps/web/wrangler.jsonc +++ b/apps/web/wrangler.jsonc @@ -21,13 +21,13 @@ "durable_objects": { "bindings": [ // The realtime hub that owns every WebSocket. The binding name is fixed. - { "name": "VITNODE_REALTIME", "class_name": "VitNodeRealtimeHub" }, - ], + { "name": "VITNODE_REALTIME", "class_name": "VitNodeRealtimeHub" } + ] }, // SQLite-backed, so the hub keeps its rooms while it hibernates. "migrations": [{ "tag": "v1", "new_sqlite_classes": ["VitNodeRealtimeHub"] }], "vars": { - "VITNODE_INSTALLATION_ID": "default", + "VITNODE_INSTALLATION_ID": "default" }, - "observability": { "enabled": true }, + "observability": { "enabled": true } } diff --git a/oxfmt.config.mts b/oxfmt.config.mts index 7ad0758ed..e2a8a551b 100644 --- a/oxfmt.config.mts +++ b/oxfmt.config.mts @@ -17,5 +17,6 @@ export default defineConfig({ "pnpm-lock.yaml", "packages/create-vitnode-app/copy-of-vitnode-app", "packages/vitnode/test-fixtures", + "**/wrangler.jsonc", ], });