Cloudflare Workers Subrequest and CPU Limit Error Handling
0 reputation · 30 Mar 2024, 15:54 UTC
Resource Limit Exceptions in Workers
Cloudflare Workers enforce strict resource constraints on the standard plan, specifically regarding CPU time and the maximum number of subrequests allowed per invocation. While CPU time tracks active processing and excludes I/O wait, the subrequest limit acts as a hard cap on outgoing fetch() calls.
When these limits are exceeded, the runtime typically triggers an exception. However, the behavior of these failures differs depending on whether the limit is hit during a synchronous execution block or an asynchronous operation. There is uncertainty regarding the consistency of the HTTP response returned to the client when a memory limit (128 MB) is breached versus when a subrequest limit is reached.
- How does the runtime distinguish between a CPU time limit exception and a subrequest limit exception when caught in a global
try/catchblock? - Is there a documented mechanism to identify which specific resource limit triggered a 1102-style error without relying on external log analysis?