Return a response when CPU time exceeded


Is there a way for a worker to return a (fallback) response when max cpu time is exceeded instead of just crashing? I know that event.passThroughOnException() will bypass the worker when there’s an exception. But i need the worker to catch the cpu timeout error.

This would be a nice feature.

To give some background:

CF will allow a few requests to go through if they exceed the CPU, then after that it hits the CPU limit exception. If your script is constantly going past the limit, it might be worth it to see if you can optimize your script, figure out what’s taking up the most time (not sure if it’s possible to measure this in production), etc.

1 Like