Fix Cloudflare Workers deploy#721
Merged
Merged
Conversation
The Cloudflare deploy failed with `ELOOP: too many symbolic links` on a path repeating `web/node_modules/jsnes/web/node_modules/jsnes/...`. `wrangler.jsonc` pointed `assets.directory` at the `web/` source tree. Wrangler walks that directory to collect static assets and follows `web/node_modules/jsnes`, a symlink back to the repo root created by the `"jsnes": "file:.."` dependency, recursing infinitely. Point `assets.directory` at `web/dist` (the Vite build output) instead, which contains only the static site. Add a `build.command` so the gitignored `web/dist` is produced during `wrangler deploy`, and set `not_found_handling` to "single-page-application" for the React Router app. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
jsnes | ac6c47b | Commit Preview URL Branch Preview URL |
May 16 2026, 04:46 PM |
The Cloudflare deploy pipeline already builds the web app: it installs dependencies and runs the configured build command (`npm run build` in `web/`, i.e. `vite build`), producing `web/dist` before the deploy command runs. The `build.command` added previously ran that build a second time, but Wrangler executes a custom build with cwd `web/` (not the repo root), so `npm --prefix web ...` resolved to the non-existent `web/web/package.json` and aborted the deploy. Remove it. Wrangler resolves `assets.directory` relative to this config file, so `web/dist` correctly points at the build output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`_redirects` contained the SPA fallback `/* /index.html 200`, a
Netlify/Cloudflare-Pages convention. Vite copies it into `web/dist`, and
Cloudflare Workers' static-asset validator rejects it:
Invalid _redirects configuration:
Line 1: Infinite loop detected in this rule. [code: 10021]
A `200` rewrite from `/*` to `/index.html` re-matches `/*`, so the
validator sees an infinite loop.
The file is now redundant on both deploy targets:
- Vercel uses `web/vercel.json` rewrites and ignores `_redirects`.
- Cloudflare Workers uses `not_found_handling: "single-page-application"`
in `wrangler.jsonc` for the SPA fallback.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the failing Cloudflare Workers deploy. Three issues, found one at a time as each deploy got further:
1.
ELOOP: too many symbolic linkswrangler.jsoncpointedassets.directoryat theweb/source tree. Wrangler walks it to collect static assets and followsweb/node_modules/jsnes— a symlink back to the repo root from the"jsnes": "file:.."dependency — recursing forever.Fix: point
assets.directoryatweb/dist, the Vite build output (nonode_modules, no symlinks). Wrangler resolves this relative to the config file, so it maps toweb/dist, which Cloudflare's build command (npm run build→vite build) produces.2. Redundant
build.commandAn interim attempt added a
build.commandto build the web app. Cloudflare's pipeline already does that, and Wrangler runs custom builds with cwdweb/, sonpm --prefix web ...resolved to a non-existentweb/web/package.json.Fix: removed it — Cloudflare's configured build command already produces
web/dist.3. Invalid
_redirects(infinite loop)web/public/_redirectscontained the SPA fallback/* /index.html 200. Vite copies it intoweb/dist, and Cloudflare Workers' static-asset validator rejects it (code: 10021) — a200rewrite from/*re-matches/*.Fix: deleted it. SPA routing is handled by
vercel.jsonrewrites on Vercel and bynot_found_handling: "single-page-application"(added here) on Cloudflare Workers.Net change
wrangler.jsonc:assets.directory→web/dist, addnot_found_handling: "single-page-application"web/public/_redirects🤖 Generated with Claude Code