Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What Error 1102 Means

Cloudflare Workers run your JavaScript or WebAssembly code on Cloudflare's network for each matching request. Each request has a CPU time limit, and the isolate that runs your code has a memory limit. When a run goes over one of them, Cloudflare ends it and the visitor sees error 1102. The limits depend on your plan and settings and change over time, so read the current values in Cloudflare's Workers documentation rather than relying on a number from a forum.

What a Visitor Can Do

Nothing on the visitor's side causes it. Reloading may work if only some requests take the heavy path. Otherwise, let the site owner know the address and the time.

CPU Time Is Not Waiting Time

CPU time counts only the time your code is actually computing. Time spent waiting for a fetch to the origin, a storage read, or another service does not count toward it. So a slow origin rarely causes error 1102; heavy work inside the Worker does. If the Worker throws an exception instead, the error is Error 1101.

Common Heavy Code Paths

  • Buffering whole bodies: reading a large response with await response.text() or .json() and then rewriting it in memory.
  • Parsing and rewriting HTML by hand: string operations and regular expressions over a large page.
  • Regular expressions that backtrack: a pattern that becomes very slow on certain input.
  • Encryption and hashing over large data.
  • Image or file processing inside the Worker.
  • Large data built on every request: big lookup tables or objects created again for each run.
  • Loops without a bound: pagination or retries that never end.

Find It in the Logs

Open the Worker in the Cloudflare dashboard and look at its metrics and logs: the invocation statuses list runs that exceeded the CPU time or memory limit, and the logs record the CPU time of each run. To follow live runs from your own terminal, run Wrangler in the Worker's project directory:

npx wrangler tail

Reproduce the request that fails and note its path, its query string, and the size of the body involved. Often only one route or one large input crosses the limit.

Fixes

  • Stream instead of buffer: pass the body through without reading it into memory, process large data with streaming APIs such as TransformStream, and use Cloudflare's streaming HTMLRewriter for changes to HTML.
  • Cache results: store computed answers so the work runs once, not on every request.
  • Move heavy work to the origin: image processing, reports, and large transformations belong on a server or in a background job.
  • Fix the expensive pattern: simplify a slow regular expression, bound the loops, build lookup tables once.
  • Raise the limit where the plan allows it: on the Workers Paid plan the CPU time limit can be raised in the Worker's settings or with cpu_ms under limits in the Wrangler configuration. The memory limit cannot be raised this way.

A Pass-Through Example

This Worker forwards the request and returns the origin's body as a stream, without reading it:

export default {
  async fetch(request) {
    const upstream = await fetch(request);
    return new Response(upstream.body, upstream);
  },
};

Add header changes on the new response object; leave the body as a stream.

When the Work Moves to Your Server

Work that leaves the Worker lands on the origin, so check that it has room: CPU, memory, and a queue for long jobs. A slow origin then shows other Cloudflare errors, such as Error 524 for responses that take too long. How a CDN and its edge code fit in front of an origin is explained in what is a CDN.

Related Errors

Was this answer helpful?
Loading...