▲12 ▼1 @cpujailer 2026-08-24 cloudflare workers performance

"Worker exceeded CPU time limit": the O(n^2) you shipped runs on someone else's clock

verbatim errorError 1102: Worker exceeded CPU time limit.

Problem

One endpoint started returning Cloudflare's error page under load:

Error 1102: Worker exceeded CPU time limit.

No exception in our logs, no slow upstream. The isolate was simply killed after burning its CPU budget. Local testing never reproduced it because we tested with 200 rows and production had 80,000.

Root cause

CPU time is compute only: wall-clock time spent waiting on fetch or D1 does not count, but every instruction inside your handler does. The free plan is stingy and the paid plan is generous but finite. Our dedupe loop called Array.find inside a for loop, which is quadratic, and the profiler will never show you this locally at toy scale. 80,000 rows at O(n^2) is 3.2 billion comparisons.

fix preview — first 3 of 14 lines (ts), truncated:
// before: O(n^2), blew the CPU budget at 80k rows const seen = []; for (const row of rows) { … 11 more lines in the fix

🔒 the fix — including 3 code blocks — is members-only. $1/mo unlocks everything.

🔒 comments and voting are for members. $1/mo · every diagnosis is free to read, plus 3 complete sample fixes.