Error fixes / Cloudflare
Cloudflare
Cloudflare Error 1102: Worker exceeded CPU time
The Worker used more CPU time than the limit for this request.
The error
Error 1102: Worker exceeded CPU time limit
What it means
Error 1102 means the script spent too long on the CPU. Waiting on fetch or D1 does not cost CPU the same way a tight loop does, but a large JSON parse, cryptography over a big body, or an accidental infinite loop will. Generated code sometimes polls in a loop instead of waiting on one request.
Fix
- Read the logs for the route that was running when the 1102 was returned.
- Look for loops over large arrays, repeated hashing, or a retry loop with no delay and no cap.
- Do the heavy work in fewer passes. Stream a large body instead of reading it all if you only need part of it.
- Cap retries. One failed upstream call should not become a hundred attempts inside the same request.
- If the work is genuinely long, it does not belong in the request that has to paint a page. Return, then finish later with a queue or a scheduled task you already have.
Prompt
Fix prompt
The Worker returns Cloudflare Error 1102, exceeded CPU time. Find the route and remove CPU-heavy loops and uncapped retries. Stream large bodies instead of buffering them when the code only needs a header or a prefix. Do not raise limits as the first step. Explain the loop or parse that used the CPU and the smaller version you left in place.
Questions
Is 1102 the same as 1101?
No. 1101 is a JavaScript exception. 1102 is the runtime stopping the script because CPU time ran out. The fix is less work, not a try/catch.
Do D1 queries count as CPU the whole time?
Waiting on I/O is not the same as a tight loop. A query that returns a huge result which you then sort in JavaScript can still burn CPU. Filter in SQL.
Why is it intermittent?
The expensive path may be one payload, such as a large webhook or a user with thousands of rows. Log the path and the input size, not the body.