Skip to content

Revision 1 — the current text. The evidence on this page is this revision’s own — it has not been carried forward from, or to, any other revision.

Debugging Workers Error 1101 (uncaught exception)

Covers finding and fixing the underlying JavaScript exception behind Error 1101, including the "script will never generate a response" variant caused by an unresolved promise. Does not cover Error 1102 (CPU time limit exceeded — a resource limit, not a thrown exception) or Error 1015 (rate limiting) — those have separate, more specific causes and remedies.

Unverifiedno reproductions yetWhy this confidence?
Revision 1published by DevYou curation

Symptoms

The diagnostic path

8 steps, exactly as this revision published them.

  1. Step 1 · StartRequests fail with Error 1101

    Cloudflare returns Error 1101 whenever a Worker's own JavaScript throws an uncaught exception. The 1101 page itself never says what threw — the real cause is always in your own logs.

    What happens next

    • passed step 2, Find the actual exception behind the 1101
  2. Step 2 · TestFind the actual exception behind the 1101

    Tail the Worker's logs while reproducing the failing request and look for the exception that immediately precedes the 1101 outcome.

    Read-onlysh
    npx wrangler tail --format pretty

    Expected result

    A line such as "Uncaught TypeError: Cannot read properties of undefined (reading 'id')" immediately before the request completes with a 500.

    What happens next

    • passed step 3, Fix the specific exception
    • failed step 4, Check for the "script will never generate a response" variant
    • unknown step 3, Fix the specific exception
  3. Step 3 · FixFix the specific exception

    Address whatever the trace points at — commonly an undefined/null property access, JSON.parse() on an empty or malformed body, or an unhandled rejection from a downstream call. Add a guard or a try/catch with a deliberate error response instead of letting it throw uncaught.

    Read-onlyts
    let body;
    try {
      body = await request.json();
    } catch {
      return new Response("Invalid JSON body", { status: 400 });
    }

    What happens next

    • passed step 5, Redeploy and repeat the failing request
  4. Step 4 · TestCheck for the "script will never generate a response" variant

    Some 1101s show no normal stack trace because nothing actually threw — the Workers runtime detected that all code finished running but no Response was ever returned. This happens when a Promise you're awaiting never resolves or rejects, or a WebSocket is left open with nothing to close it.

    Read-onlysh
    npx wrangler tail --format pretty

    Expected result

    A message containing "The script will never generate a response" rather than a specific exception.

    What happens next

    • passed step 6, Ensure every code path resolves a Response
    • failed step 7, Not resolved by inspecting your own code — escalate
    • unknown step 7, Not resolved by inspecting your own code — escalate
  5. Step 5 · Verify the fixRedeploy and repeat the failing request

    Deploy the fix and re-send the request (or input) that previously triggered the 1101.

    Changes statesh

    Changes system or service state. Review before running.

    Deploys the corrected Worker code to production, replacing the currently live version.

    npx wrangler deploy

    Expected result

    wrangler tail shows the expected status code with no exception, and no 1101.

    What happens next

    • passed step 8, Resolved
    • failed step 7, Not resolved by inspecting your own code — escalate
    • unknown step 7, Not resolved by inspecting your own code — escalate
  6. Step 6 · FixEnsure every code path resolves a Response

    Find the Promise your handler depends on that can be left unresolved (a setTimeout-based promise with no fallback, an event listener that's never fired) and guarantee it resolves or rejects. Enabling the no-floating-promises ESLint rule catches most of these at review time.

    Read-onlyts
    let { promise, resolve } = Promise.withResolvers();
    setTimeout(resolve, 0); // ensure this always fires
    return promise.then(() => new Response("ok"));

    What happens next

    • passed step 5, Redeploy and repeat the failing request
  7. Step 7 · EndNot resolved by inspecting your own code — escalate

    If wrangler tail shows nothing useful in either form, this may be a Workers runtime issue rather than application code. Contact Cloudflare Support with the Ray ID from the error page, the Worker name, recent code changes, and steps to reproduce.

  8. Step 8 · EndResolved

    The request path handles the previously-unhandled case and no longer throws an uncaught exception.

Sources

Why this confidence?

What would strengthen it: 6 more independent reproductions. Reproductions from 3 more distinct environments.

This counts only what was recorded against revision 1 itself. Nothing reported against another revision is included here — see the revision history for why.