986 words
5 minutes

Cloudflare Workers Error 1102: Find CPU or Memory Limit First

2026-08-18
DevOps
Cloudflare
/
DevOps
/
JavaScript
/
Troubleshooting

Cloudflare Workers error 1102 means the Worker exceeded a runtime resource limit. The two important paths are CPU time and memory: a tight loop or large synchronous parse can exhaust CPU, while buffering a request, response, or growing data structure can exhaust the isolate’s memory. The error is not enough information to choose the fix.

Start with the invocation logs and the route that returned the error. Cloudflare’s Error 1102 documentation explicitly separates CPU and memory debugging, so do not respond to every 1102 by increasing a plan or rewriting fetch() calls.

Separate CPU time from memory#

SignalCPU-time pathMemory path
Typical code shapeLarge loops, JSON parsing, regex work, SSR, image or document transformsarrayBuffer(), text(), large JSON objects, unbounded arrays, buffered responses
What to inspectInvocation CPU time, route timing, local profileObject sizes, buffered bodies, global state, concurrent requests
First fixReduce synchronous work or split the operationStream data, cap input, and release large objects earlier
Plan changeA paid plan can expose a higher CPU-time setting for CPU-bound workA plan change does not make an isolate’s memory strategy safe

Cloudflare’s current Workers limits list a 128 MB per-isolate memory limit. They also document CPU limits by plan, including 10 ms per HTTP request on the Free plan and a higher configurable limit on paid plans. Treat those numbers as platform settings to verify on the day of deployment, not constants to copy into application logic.

Read the invocation that returned 1102#

Preserve the request path, deployment version, timestamp, status, and resource information from Workers Logs. The Workers errors and exceptions reference maps 1102 to exceeded CPU time and distinguishes it from other runtime errors.

Use a minimal reproduction with a known input size:

request size -> route -> CPU time -> memory behavior -> response

Compare a small and a large input, then compare the route with expensive work disabled. The goal is to find whether the failure threshold follows input size, synchronous computation, or accumulated state. A single successful request does not prove that the route stays below the limit for the production payload.

For local profiling, run the Worker through the same development or build path that production uses and inspect the expensive synchronous section. Cloudflare recommends DevTools CPU profiling for CPU-heavy code and memory snapshots for allocation problems. Add temporary timing around parsing, transformation, and serialization rather than measuring only the whole request.

Reduce CPU-bound work#

When the logs point to CPU time, start with code that runs before and after network calls:

  • avoid repeated parsing or serialization of the same payload;
  • replace nested scans with an indexed lookup where the data shape allows it;
  • process a large collection in bounded batches instead of one synchronous loop;
  • cache stable computed results outside the hot path when the cache semantics are safe;
  • move long-running work to a queue, Workflow, or another execution boundary when one request should not own it.

Waiting for network I/O is not the same as spending CPU. Cloudflare’s performance documentation explains how to measure CPU-intensive sections and notes that subrequest time is not CPU time. Optimize the synchronous work around fetch(), not just the number of upstream calls.

If the workload is genuinely CPU-bound and fits the platform’s request model, a paid CPU-time setting may be appropriate. Verify the configured limit and retest the same route; do not use a plan change to hide an unbounded loop or a request that should be processed asynchronously.

Reduce memory pressure#

When the failure follows payload size or concurrent requests, look for buffering first:

// Risky for unbounded input
const text = await request.text();
const data = JSON.parse(text);
// Prefer a bounded contract or streaming path for large input.
const MAX_BYTES = 10 * 1024 * 1024; // example application limit
const contentLength = Number(request.headers.get('content-length') || 0);
if (contentLength > MAX_BYTES) {
return new Response('Payload too large', { status: 413 });
}

The example is an application guard, not a replacement for Cloudflare’s edge limits. For large bodies, avoid keeping the full request and transformed result in memory at the same time. Use a ReadableStream or TransformStream when the format supports incremental processing, and avoid accumulating every item in a global array.

If the request is rejected before the Worker runs, that is a request-size problem rather than a 1102 memory failure. The Cloudflare Workers 413 guide covers the edge, zone, and origin boundaries separately.

Verify the fix with a boundary matrix#

Run the route against inputs that are just below and above the suspected threshold:

TestEvidence to keep
Small inputNormal response and baseline CPU or memory observation
Large inputWhether the failure follows size and whether the Worker was invoked
Expensive transformation disabledResource change that isolates the hot section
Repeated requestsWhether memory grows across invocations or only within one request
Paid CPU setting, if usedNew configured limit and the same workload’s result

After deployment, watch the same route and version in Workers Logs. A 1102 count that falls after a code change is useful evidence, but it does not replace checking tail latency, input limits, and error handling for the next larger payload.

The practical takeaway is to classify error 1102 before changing the code or plan. CPU needs less synchronous work or a deliberate CPU budget; memory needs bounded data flow and less buffering. The log and a small reproducible input tell you which path you are actually on.

FAQ#

Does fetch() time count toward a Worker CPU limit?#

Network wait time such as a fetch() subrequest does not count as CPU time. The code that parses, transforms, loops, and serializes around that request still consumes CPU and can exceed the limit.

Does a paid Workers plan remove error 1102?#

No. A paid plan can provide a higher CPU-time setting for eligible workloads, but error 1102 can also mean the isolate exceeded its memory limit. A plan change cannot replace bounded allocations or streaming.

Is error 1102 the same as a 413 request-body error?#

No. A 413 can be returned by an edge, zone, API, or origin request-size limit, sometimes before the Worker runs. Error 1102 is a Worker runtime resource failure after the Worker is involved.

References:

Cloudflare Support: Error 1102

Cloudflare Workers limits

Cloudflare Workers errors and exceptions

Cloudflare Workers performance and timers

Cloudflare Workers Error 1102: Find CPU or Memory Limit First
https://laplusda.com/en/posts/cloudflare-workers-error-1102-cpu-memory/
Author
Zero
Published at
2026-08-18
License
CC BY-NC-SA 4.0
Was this article useful?

Report a typo or broken link, or suggest a related topic.