Does cloudflare worker need warming up or something?

My website makes a request to a cloudflare worker which makes a request to another backend api. "Browser with Turnstile token" ==> Cloudflare Worker named "Fetch" ==> Backend engine server hosted elsewhere. It seems like if I don't trigger it on my website for a few days that whenever I try the first several times it doesn't work, then all of a sudden a few minutes later it works flawlessly every time. I then go check my "fetch" worker logs and I got nothing captured as to why that might be happening thinking maybe I have a logic error. Is it possible that the fetch worker does a startup and takes so long that my code errors out? When I use to run this on a dedicated server before cloudflare with nodejs servers responding to the fetch I never had this issue. If the fetch worker does indeed take time to startup is there any log that I can check to see how long?
1 Reply
SuperHelpflare
SuperHelpflare2mo ago
Support AI
Based on the provided documentation, it's possible that the issue you're experiencing is related to the Cloudflare Worker's startup time. According to the documentation, Cloudflare Workers can take some time to start up, especially if they haven't been triggered for a while. You can check the Worker's logs to see if there are any errors or warnings related to startup time. However, the documentation doesn't provide a specific log that shows the startup time of a Worker. One possible solution is to use the wrangler dev command to run your Worker locally and test its startup time. This can help you identify if the issue is related to the Worker's code or the Cloudflare platform. Additionally, you can try to use the fetch API with a timeout to see if the issue is related to the backend API's response time. You can also try to add some logging statements in your Worker's code to see if there are any errors or warnings during the startup process. It's also worth noting that Cloudflare Workers have a concept of "cold start" which can cause delays in the first few requests after a period of inactivity. You can try to use the min_instances setting in your wrangler.toml file to keep a minimum number of instances of your Worker running, which can help reduce the cold start time. You can refer to the following documentation for more information: * Cloudflare Workers documentation * Wrangler documentation * Fetch API documentation Source: https://developers.cloudflare.com/workers/
This is an AI generated response, it may not be 100% accurate. Please validate the output. You can ask followups by replying to this message or mentioning me.

Did you find this page helpful?