Cloudflare Workers errors
How do I fix Cloudflare Error 1102, Worker exceeded resource limits?
Error 1102 "Worker exceeded resource limits" means a Cloudflare Worker went over its CPU time limit or its 128 MB memory limit, so Cloudflare stopped it. If it's CPU on Workers Paid, the fastest fix is raising cpu_ms in your Wrangler config: the default is 30 seconds and the maximum is 5 minutes. On Workers Free the limit is 10 ms per request, so you cut the work or move to Paid.
Check which limit it was before you change anything: the dashboard shows Exceeded CPU Time Limits or Exceeded Memory under Metrics, Errors, Invocation Statuses. If the Worker's CPU limit is exactly 50 ms and nobody on your team set it, it may be a Costbrake brake, covered below.
CPU or memory: find out which
- Dashboard: your Worker's Metrics, then Errors, then Invocation Statuses shows
Exceeded CPU Time LimitsorExceeded Memory. - Analytics and Logpush: the invocation outcome is
exceededCpuorexceededMemory. - Workers Logs: CPU time is in the invocation log, so you can see which routes or requests burn the most.
- DevTools: profile CPU or memory locally to find the expensive code.
Only running code counts toward CPU time. Cloudflare: "Time spent on network requests (fetching, responding) does not count towards CPU time." A Worker that waits on a slow API uses almost no CPU; one that parses a huge JSON body or loops over big arrays can use a lot.
Workers limits per plan
| Limit | Workers Free | Workers Paid |
|---|---|---|
| CPU time per HTTP request | 10 ms | 30 seconds by default, up to 5 minutes |
| CPU time per Cron Trigger | 10 ms | 30 seconds for intervals under 1 hour, 15 minutes for 1 hour or more |
| Memory per isolate | 128 MB | 128 MB |
| Custom CPU limit | Not available | Up to 300,000 ms with limits.cpu_ms |
Most Workers never get close. Cloudflare puts the average at about 2.2 ms of CPU per request, and heavier work like authentication, server-side rendering or parsing large payloads at 10 to 20 ms. Each isolate has "some built-in flexibility" for a Worker that runs over now and then, but one that hits the limit consistently gets terminated.
Memory works per isolate, not per request: "an isolate may be handling multiple requests concurrently." Several heavy requests at once share the same 128 MB.
Fix a CPU time 1102
- Raise the limit (Workers Paid). Set
cpu_msunderlimitsin your Wrangler config, or change the CPU time limit in the dashboard under Workers & Pages, your Worker, Settings. - Cut the CPU work. Cloudflare's list: fewer loop iterations, cheaper JSON parsing, caching computed values, and breaking big operations into smaller chunks.
- Move the heavy part. Offload expensive computation to Durable Objects, or process data in smaller chunks across several requests.
{
"limits": {
"cpu_ms": 300000
}
}A higher limit also lets a runaway loop run longer before Cloudflare stops it. How CPU time is billed is in Cloudflare Workers pricing; read it before you set 5 minutes on every Worker.
Fix a memory 1102
- Stream request and response bodies with
TransformStreamornode:streaminstead of buffering them whole. - Keep large objects out of global scope, and watch code that keeps appending to strings or arrays.
- If you see
Memory limit would be exceeded before EOF, the Worker tried to buffer a body bigger than the limit.
When a Costbrake brake is the cause
Costbrake's Cloudflare brake Cap CPU time per request sets a 50 ms CPU limit on one Worker, so expensive requests fail with Error 1102 instead of running up CPU charges. That 1102 is the brake doing its job. It never fires by itself: a Costbrake admin picks the Worker, types the connection's name to confirm and clicks Brake now. It needs Workers Paid, the only plan with custom CPU limits.
Signs it was the brake: the Worker's CPU limit reads 50 ms, and Cloudflare saved the change as a new version with the message Costbrake brake: CPU limit. To lift it, an admin clicks Restore in Costbrake, which puts back the Worker's earlier CPU limit, or the 30-second default if it had none. If someone already moved the limit off 50 ms, Restore leaves it alone. You can also set cpu_ms yourself.
Costbrake reads Cloudflare usage every 5 minutes on Pro and Team and every minute during a spike, a few minutes behind real time, and billed dollars daily. Brakes come with Pro and Team; see pricing, the Cloudflare integration and Cloudflare billing alerts.
Questions and answers
Is Error 1102 the same as Error 1101?
No. Error 1101 is a Workers JavaScript runtime exception, meaning your code threw an error. Error 1102 means the Worker ran out of CPU time or memory. The fixes differ: debug the exception for 1101, and raise the limit or cut the work for 1102.
Does waiting on fetch count toward the Workers CPU limit?
No. Cloudflare only counts time spent running your code. Waiting on fetch calls, KV reads or database queries doesn't count, so a Worker can wait a long time on a slow API without hitting Error 1102.
Can I raise the CPU limit on the Workers Free plan?
No. Workers Free allows 10 ms of CPU per HTTP request and per Cron Trigger. Custom CPU limits need Workers Paid, where the default is 30 seconds per request and you can raise it to 5 minutes.
Why do I only get Error 1102 some of the time?
Two common reasons. Each isolate has some built-in flexibility, so a Worker that runs over now and then isn't always stopped, while one that hits the limit consistently is. And memory is shared per isolate, so several heavy requests at once can push it past 128 MB together.
Can Workers limits show up as a 503 instead of 1102?
Yes. Cloudflare lists Error 503, service temporarily unavailable, as something Workers CPU or memory limits can cause. Check Invocation Statuses in the dashboard to see whether the Worker hit a limit.
Did Costbrake cause my Error 1102?
Only if an admin in your Costbrake workspace braked that Worker. Then its CPU limit is 50 ms and Cloudflare shows a version with the message Costbrake brake: CPU limit. An admin can click Restore in Costbrake to put the old limit back, or you can set cpu_ms yourself.
Sources
Updated