521 origin response from worker

We have some routes set-up on workers which fetch content using a request to netlify and return the response. The content is all static, html, css, js files.

For example:

https:ourdomain/ver/10/cdn/index.html —> https:netlifyapp/ver/10/cdn/index.html

Our worker takes the request and makes a get request to the new URL on Netlify and returns the content.

This has worked fine for 12 months, last 7 days multiple workers, using multiple netlify sites are failing with 522 and under the worker stats we see many disconnects.

Any ideas how we can resolve this or achieve with a more reliable solution? We have cache turned on so the worker does not call the destination.

 response = await fetch(new_url,{cf: { cacheTtl: 21600,cacheEverything: true}});
 html = await response.text();
   
  // Return modified response.
  var res =  new Response(html, {
    status: response.status,
    statusText: response.statusText,
    headers: response.headers
  });
  res.headers.set("cache-control", "public, max-age=86400, must-revalidate");

I’m not sure why that would fail, the code looks fine.

Maybe try asking on the Workers discord server here

Someone may be able to help figure it out :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.