Skip to content
Cloudflare Docs

Error 1102

Error 1102: Worker exceeded resource limits

This error indicates that a Cloudflare Worker has exceeded its CPU time limit or memory limit.

Exceeded CPU time

A Cloudflare Worker exceeds a CPU time limit. CPU time is the time spent executing code (for example, loops, parsing JSON, etc). Time spent on network requests (fetching, responding) does not count towards CPU time.

Debugging

To identify CPU-intensive code:

  1. Use CPU profiling with DevTools locally to identify expensive operations.
  2. Review Workers Logs - CPU time is surfaced in the invocation log. This can help find if specific routes or requests are consuming high CPU time.

Resolution

Contact the developer of your Workers code to optimize code for a reduction in CPU usage. Common optimization strategies include:

  • Reducing the number of iterations in loops
  • Optimizing JSON parsing operations
  • Caching computed values
  • Breaking up large operations into smaller chunks

You can also increase the CPU time limit on the Workers Paid plan up to 5 minutes for CPU-bound tasks.

Exceeded memory

A Cloudflare Worker exceeds the 128 MB memory limit. This is a per-isolate limit, an isolate may be handling multiple requests concurrently.

Debugging

To identify memory issues:

  1. Use memory profiling with DevTools locally to take memory snapshots and identify leaks.
  2. Look for patterns like buffering a body which could be large (request or response), large objects stored in global scope or accumulating data in arrays.

Resolution

To avoid exceeding memory limits:

  • Avoid buffering large objects or responses in memory
  • Use streaming APIs such as TransformStream or node:stream to process data without buffering
  • Avoid storing large objects in global scope
  • Be cautious with operations that accumulate data (e.g., appending to strings or arrays repeatedly)
  • Error 1101 - Workers JavaScript runtime exception
  • Error 503 - Service temporarily unavailable (can be caused by Workers CPU or memory limits)