Cloudflare Workers > Paid Unbound > script time limit

I signed up for Cloudflare Workers, upgraded to Paid Unbound, but still getting the following exceptions in Console: “Uncaught (in response) Error: Worker exceeded CPU time limit.” and “script exceeded time limit” when previewing my edits to a worker.

Isn’t upgrading to Unbound supposed to allow requests up to 30 seconds?
The requests finish for me right away with these errors.

I’d like to use some of the Workers’ examples from cf-workers/streaming-optimizations at master · pmeenan/cf-workers · GitHub

Can someone please help me figure out how to let my requests run up to 30 seconds?

Thank you.

Make sure you change your usage model in the settings tab for your Worker

1 Like

Mine is set to Unbound, which I thought is more “advanced” and would allow script execution to last longer than 50ms…

Did I misunderstand that?

Yep, Unbound does give 30 seconds wall clock. Are you seeing issues in the deployed Worker? I’m not sure the preview editor actually knows about your model. If you haven’t already, I’d deploy and test the deployed worker

It works fine when I use the simplest code, such as

 * Handle all requests. Proxy requests with an x-host header and return 403
 * for everything else

addEventListener("fetch", event => {
    const host = event.request.headers.get('x-host');
        if (host) {
          const url = new URL(event.request.url);
          const originUrl = url.protocol + '//' + host + url.pathname +;
          let init = {
             method: event.request.method,
             redirect: "manual",
             headers: [...event.request.headers]
          event.respondWith(fetch(originUrl, init));
        } else {
           const response = new Response('x-Host headers missing', {status: 403});

But when I use something like, then I’m seeing the following returned as 404:

Deployed and tested in my browser with the ModHeader browser extension (passing the site to modify via the “x-host” header) and via WebPageTest.