What Error 1101 Means
Cloudflare Workers are small JavaScript programs that run on Cloudflare's network and answer requests before, or instead of, the origin server. When a request matches a route that a Worker serves and the Worker's code throws a JavaScript exception that keeps it from returning a response, Cloudflare shows error 1101. The fault is in the Worker or its configuration, not in the browser.
What a Visitor Can Do
Nothing on the visitor's side causes it. Reload later, or send the site owner the time, the address, and the Ray ID from the error page.
Find the Exception in the Logs
Stream the Worker's live logs with Wrangler, Cloudflare's command-line tool, while you repeat the failing request:
npx wrangler tail my-worker
In a second terminal:
curl -i https://example.com/failing/path
The tail output shows the request, its outcome, and any exceptions with their messages. In the dashboard, the Worker's Logs view shows the same exceptions, and Workers Logs keeps past ones for later searching when it is turned on. The message usually points to the cause, such as reading a property of undefined. Running the Worker locally with npx wrangler dev and sending it the same request is another way to reproduce the error.
Catch Errors in the Handler
Wrap the handler so an unexpected error returns a clear response and is logged, instead of becoming a 1101 page:
export default {
async fetch(request, env, ctx) {
try {
return await handleRequest(request, env);
} catch (err) {
console.error("handler failed", err.stack);
return new Response("Internal error", { status: 500 });
}
},
};
Await every promise whose result you depend on: a rejected promise that is not awaited escapes the try block, and promises that are not awaited, returned, or passed to ctx.waitUntil() may be canceled when the request ends. A 500 from your own code is still an error, but it is logged and controlled; the status codes themselves are explained in 500 Internal Server Error.
Missing Bindings and Variables
Workers reach storage, secrets, and other services through bindings on the env object. If a binding is missing in the environment you deployed to, the code reads undefined and throws on the first use. Check:
- The Wrangler configuration file: each binding is declared, with the right name, for the environment you deploy.
- Secrets: a secret set for one environment is not present in another; set it with
npx wrangler secret put NAME, adding--envand the environment's name where needed. This creates a new version of the Worker and deploys it at once. - The dashboard: the Worker's settings list the bindings and variables it actually has.
A Route Attached by Mistake
A Worker route such as example.com/* catches every path on the hostname, including ones the Worker was never written for. If the error appears only on some paths, open the zone's Workers routes and check which pattern matches the failing address. Narrow the pattern, or remove a route left over from a test.
Common Code Causes
- Parsing input:
JSON.parseon a body that is not JSON throws; validate first. - Reading a body twice: a request or response body can be read once; clone it if you need it again.
- Failed subrequests: a
fetchthat fails at the network level rejects; catch it and return a fallback or a 5xx response. - Unexpected shapes: a header or query parameter that is missing produces
null; check before use.
Confirm the Fix
Deploy, keep the tail running, and request the failing address again:
curl -sI https://example.com/failing/path | head -1
The expected status and no exception in the tail mean the Worker handles the request. If the request should reach the origin, see what a CDN is for how traffic flows through the edge, and HTTP status codes for the code the origin returns.