fetch() calls throwing Connect Timeout Errors
We are fetching a lof images from our CMS during build. We are recently getting
Connect Timeout Error
a lot. First, it was one image. But now the more images are getting added to the CMS, the more we are getting Connect Timeout Error
. Why is it happening? Is there any concurrent request limit in Cloudflare Pages? And if there's a limit, should Cloudflare automatically handle this?8 Replies
AFAIK there is no built-in limit during the build process, but perhaps there is as an anti abuse method. The build environment is just a linux container. Have you tried running the build locally, does it happen then?
There is a concurrent fetch request limit in workers / pages functions, but that has no impact on build.
It didn't use to happen locally
But now I see it's happening locally too
In Cloudflare, I'm getting 100+ errors but locally I'm getting 2
So, that's why it was not happening before locally when in Cloudflare only 1/2 errors were happening
It's probably a bug in
undici
Perhaps it's your CMS' anti bot / anti DDOS protection? The CF build containers are run on datacenter IPs, those are inherently trusted less than residential IPs
GitHub
fetch times out in under 5 seconds · Issue #1531 · nodejs/undici
Bug Description When trying to fetch a URL a fetch failed error is thrown with the code as code: 'UND_ERR_CONNECT_TIMEOUT' , This error is thrown at a request that barely takes 5 - 6 second...
Probably that's not the case
yup!
How did you do that?? By fetching them synchronously??
Very much sounds like your CMS is blocking you. What CMS are you using? Do they have CDN-links to your assets that aren't restricted?
Strapi
There are actually two issues happening, the first one is the VPS that is hosting the Strapi CMS isn't being able to handle hundreds of requests simultaneously
And the second issue is https://github.com/nodejs/undici/issues/1531 which is related with Happy Eyeballs support in Node.js
GitHub
fetch times out in under 5 seconds · Issue #1531 · nodejs/undici
Bug Description When trying to fetch a URL a fetch failed error is thrown with the code as code: 'UND_ERR_CONNECT_TIMEOUT' , This error is thrown at a request that barely takes 5 - 6 second...