This error is thrown when your Worker exceeds the CPU limit for a single invocation. This is a fatal error and there is no way to catch it. You need to either make sure the Worker will not exceed this limit or handle the error client-side when it does.
If your origin server can support “Accept-Range” HTTP 206 Partial Content then you can split up the work load into chunks that is executed in parallel 2 workers at a time and automatically cycling through Workers as their CPU Time is reached. Although you cannot measure the CPU Time from within a Worker, your workload should be fairly predictable so you can tune-in the right amount of work per sub-request as to not exceed the CPU Time.
The figures quoted by @albert are the CPU Time which I want to clarify that unlike other serverless platforms (namely GCP and AWS) will quote the milliseconds in “Wall Time”. Cloudflare Free and Bundle plans are quoting “CPU Time” which is very different. For the Worker Bundle plan, 50 ms CPU Time is actually very generous and should be plenty time to process at least a few hundred megabytes of your file decryption, obviously depending on your algorithm.
With this approach, you can achieve equivalent “Wall Time” far greater than what you could achieve with even the Worker Unbound plan. And you can have single long-running request of real time over 12 hours despite what Cloudflare officially says Limits · Cloudflare Workers docs.
I have a real example I can share with you which is built on the Workers Bundle plan which regularly has single long-running requests open for over 12 hours even though the CPU Time is limited to 50ms.
Although you maybe cycling through multiple sub-requests, the end-user and their browser is none-the-wiser as the Worker is seamlessly stitched together sub-requests into a single long-running request.
It’s also worth noting about the CPU Time “limit”. When they say the CPU Time is “limited”, it’s actually not a hard limit, even if the CPU Time goes over on an individual request, that individual request won’t be killed nor will the Worker be terminated. These CPU Time “limits” are more of an upper policy for a certain percentile of your requests to be under.