Skip to content

Fix Cloudflare Workers deploy#721

Merged
bfirsh merged 3 commits into
mainfrom
fix-cloudflare-deploy-eloop
May 16, 2026
Merged

Fix Cloudflare Workers deploy#721
bfirsh merged 3 commits into
mainfrom
fix-cloudflare-deploy-eloop

Conversation

@bfirsh
Copy link
Copy Markdown
Owner

@bfirsh bfirsh commented May 16, 2026

Fixes the failing Cloudflare Workers deploy. Three issues, found one at a time as each deploy got further:

1. ELOOP: too many symbolic links

wrangler.jsonc pointed assets.directory at the web/ source tree. Wrangler walks it to collect static assets and follows web/node_modules/jsnes — a symlink back to the repo root from the "jsnes": "file:.." dependency — recursing forever.

Fix: point assets.directory at web/dist, the Vite build output (no node_modules, no symlinks). Wrangler resolves this relative to the config file, so it maps to web/dist, which Cloudflare's build command (npm run buildvite build) produces.

2. Redundant build.command

An interim attempt added a build.command to build the web app. Cloudflare's pipeline already does that, and Wrangler runs custom builds with cwd web/, so npm --prefix web ... resolved to a non-existent web/web/package.json.

Fix: removed it — Cloudflare's configured build command already produces web/dist.

3. Invalid _redirects (infinite loop)

web/public/_redirects contained the SPA fallback /* /index.html 200. Vite copies it into web/dist, and Cloudflare Workers' static-asset validator rejects it (code: 10021) — a 200 rewrite from /* re-matches /*.

Fix: deleted it. SPA routing is handled by vercel.json rewrites on Vercel and by not_found_handling: "single-page-application" (added here) on Cloudflare Workers.

Net change

  • wrangler.jsonc: assets.directoryweb/dist, add not_found_handling: "single-page-application"
  • delete web/public/_redirects

🤖 Generated with Claude Code

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>
@cloudflare-workers-and-pages
Copy link
Copy Markdown
Contributor

cloudflare-workers-and-pages Bot commented May 16, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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>
@bfirsh bfirsh changed the title Fix Cloudflare deploy ELOOP by deploying built site Fix Cloudflare Workers deploy May 16, 2026
@bfirsh bfirsh merged commit 82d0850 into main May 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant