Cloudflare Workers Error 1101 'Worker Threw Exception': Fix
Your Worker returns Cloudflare error 1101 and the page gives no details. Turn on logs, find the real exception, fix the usual causes, and make the next failure show up before users report it.
Cloudflare error 1101 means your Worker threw a JavaScript exception that nothing caught. The error page does not say which one, so the fix starts in the logs: turn on Workers Logs or run wrangler tail, repeat the failing request, read the stack trace, and fix that line. Then wrap your handler in a try/catch so the next bug returns a controlled 500 and a log entry instead of a Cloudflare error page.
The 1101 page is the same for every cause: a missing secret, a failed fetch, a null value, a bad import, or a crash during start-up. Cloudflare's own error 1101 page says the fix is to correct the exception in your Worker code. This guide shows how to find that exception fast and how to stop it from happening silently again. It is written for small teams that deploy a Worker and do not have a platform engineer.
Step 1: Confirm It Is 1101 and Not 1102
The two codes look alike but need different fixes.
- 1101: your code threw. Fix the code.
- 1102: your Worker used more CPU time or memory than its limit allows. Fix the heavy work or raise the limit. See error 1102.
CPU time counts only time your code runs. Waiting on fetch, KV or a database does not count toward it, so a slow upstream API is not a 1102 cause. If you see 1102, look for big synchronous loops, large JSON parsing or heavy crypto. The rest of this post is about 1101.
Also check whether it is every request or only some. A Worker that fails on every request usually has a start-up problem. One that fails on some requests has a data or input problem.
Step 2: Turn On Logs So the Exception Is Recorded
If you have no logs, the stack trace is gone. In your Wrangler config, enable observability:
// wrangler.jsonc
{
"name": "my-api",
"main": "src/index.ts",
"compatibility_date": "2026-11-01",
"observability": {
"enabled": true
}
}
Deploy with npx wrangler deploy. Uncaught exceptions now appear in the Workers Logs view of the dashboard. Keep the compatibility date current, because runtime behavior changes between dates.
For a live look while you reproduce the problem, stream logs from the terminal:
npx wrangler tail my-api --format pretty
Now hit the failing URL. The exception, message and stack trace print as the request fails. The Cloudflare page on Workers errors and exceptions lists the common codes and the same advice to read logs first.
Step 3: Check the Usual Causes in Order
Once you have the message, it almost always matches one of these.
A missing or misnamed binding or secret. Locally you had a .dev.vars file. In production the secret was never set, so env.API_KEY is undefined and the next line throws.
npx wrangler secret put API_KEY
npx wrangler secret list
A failed fetch that you did not check. fetch only rejects on network errors. A 500 from an upstream API resolves normally, and then await res.json() throws on an HTML error page.
const res = await fetch("https://api.example.com/items");
if (!res.ok) {
throw new Error(`upstream ${res.status}`);
}
const items = await res.json();
Reading a body twice. A Request or Response body can be read once. Call .clone() first if you need it again.
Node-only code. Workers are not Node.js. A package that needs fs or other Node APIs fails unless you enable the Node compatibility flag and the API is supported. Check the Workers docs for the specific module.
An error at the top level of the module. Code that runs when the file loads, such as parsing a config value, can throw before any request is handled. That makes every request a 1101.
Handlers other than fetch. Scheduled (cron) and queue handlers can also throw. Their failures do not show up as a page, so they are easy to miss. Read the logs for those handlers too.
Step 4: Add a Top-Level Try/Catch
A bug will happen again. Make sure it leaves a record and returns a normal response.
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
try {
return await handle(request, env, ctx);
} catch (err) {
const e = err instanceof Error ? err : new Error(String(err));
console.error(JSON.stringify({
level: "error",
message: e.message,
stack: e.stack,
url: request.url,
method: request.method,
}));
return new Response(JSON.stringify({ error: "internal_error" }), {
status: 500,
headers: { "content-type": "application/json" },
});
}
},
};
Your clients now get JSON with a 500 instead of a Cloudflare HTML page, and your logs carry the stack and URL. This is a safety net. It does not fix the bug, so keep reading the logs.
Do the same inside scheduled and queue handlers, and log before you re-throw if you want the platform to retry.
Step 5: Reproduce It Locally Before You Redeploy
Run the Worker locally with npx wrangler dev. Put the secrets it needs in a .dev.vars file that is not committed. Send the same request that failed. If the bug only appears with production data, copy a sanitized version of that input.
When it passes locally, deploy and keep wrangler tail open. Repeat the request that failed. Cloudflare's guidance is the same: after you identify the exception, redeploy with a fix and keep tailing the logs to confirm it is gone.
Step 6: Get Told Before Users Notice
Logs help only if someone looks. A Worker that starts throwing after a Friday deploy can return 1101 to some users for hours with no alert.
Cheap options that work:
- Add an uptime check on a real endpoint that exercises your code path, not only the home page. A plain 200 check misses broken flows, as covered in Uptime Monitor Says Up but Users See Errors.
- Alert on the error rate, not on single errors, so one bad bot request does not wake you.
- Watch the "invocation statuses" metrics in the Cloudflare dashboard after each deploy.
For a broader view of when to alert and when to stay quiet, see Too Many Production Alerts? How to Fix Alert Noise Fast.
How Relia Helps
Relia watches the users, APIs and servers of a live product and joins related signals into one incident explained in plain words, such as a deploy followed by a jump in failing requests. It shows which users were affected and, when there is a stack trace, gives a fix plan with the file and line. After a deploy it checks whether the fix worked. It also runs uptime monitors and checks of key pages. Relia supports edge functions, and Go, Rust, Java, .NET and Ruby work through standard OpenTelemetry. Relia does not change your code. See the live demo or start on the Free plan.
FAQ
What is the difference between error 1101 and error 1102?
1101 means your Worker threw an unhandled exception. 1102 means it exceeded its CPU time or memory limit. Read the error code first, because the fixes are different.
How do I see the stack trace for a Worker exception?
Enable observability in your Wrangler config and open Workers Logs, or run npx wrangler tail <name> and repeat the failing request. The 1101 page itself does not include the stack.
Does a slow fetch cause error 1102?
No. Cloudflare counts CPU time, not time spent waiting on network calls, KV reads or database queries. Heavy parsing, loops and computation are the usual causes.
Can a cron or queue Worker cause error 1101?
Yes. Scheduled and queue handlers can throw too, and nobody sees an error page. Check their logs and add a try/catch with logging in each handler.
Why does my Worker work with wrangler dev but fail after deploy?
The most common reason is a secret or binding that exists locally in .dev.vars or your config but was never set for the deployed Worker. Run npx wrangler secret list to compare.