Cloudflare Error 1101: "Worker Threw a JavaScript Exception"

Your Worker code threw an unhandled exception while handling the request. It's an application bug — find the exception in logs (wrangler tail or dash logs), don't guess from the 1101 page.

What you'll see

Root causes

Unhandled exception in your handler (the obvious)

TypeError on undefined, JSON.parse on non-JSON, undefined env binding. The stack trace in `wrangler tail` or dashboard → Workers → Logs names the exact line.

Missing/renamed binding

Deploying with metadata that dropped or renamed a KV/D1/secret binding makes env.X undefined at runtime — code that worked last deploy now throws. Compare bindings in the deploy metadata.

CPU limit or subrequest explosions under load

Exceptions from exceeding limits surface as 1101-ish failures under traffic only. Look for 'Exceeded CPU' or 'Too many subrequests' in logs.

Fix it

  1. Tail live logs and reproduce
    wrangler tail --format pretty   # hit the failing URL: the exception + stack trace appear in the stream
  2. Verify bindings against what your code expects
    wrangler deployments list 2>/dev/null || wrangler whoami ; # compare [vars]/bindings in wrangler.toml vs env usage in code
  3. Add a top-level try/catch so bugs degrade gracefully
    export default { async fetch(req, env, ctx) { try { return await handler(req, env); } catch (e) { return new Response('temporarily unavailable', { status: 500 }); } } }
  4. For load-only failures: check limits and caching
    # logs show 'Exceeded CPU' (optimize loops/AI calls) or 'Too many subrequests' (cache fetch results)

Field note

1101 pages are customer-visible — ship the try/catch so a bug becomes a 500 with logging instead of a Cloudflare-branded error page. Source maps deploy with wrangler by default in dev: production traces without them are much less useful; keep the upload.

Common questions

Where exactly do I see the exception?

wrangler tail (live) or dashboard → Workers & Pages → your worker → Logs (recent invocations). The stack trace includes the file and line — that's the whole debug.

The same code worked before I redeployed. What broke?

Deploy metadata (bindings!) changed: a missing binding turns env.MY_KV into undefined and the first use throws. Diff the bindings in the deployment, not just the code.

Ship it right the first time

Our most-documented failures, packaged as ready-to-ship starter kits: Docker, Kubernetes, and Terraform.

Browse the template store →

One-time. Yours to modify. Instant download from the NinjaOps template store.