Scheduled worker gets an error in production, not locally

I have a scheduled task worker that does a fetch call to an API and then does some work with the results. This is all running fine locally. However, in production, when I make a fetch call to the remote API, I get: “error code: 521”. To be clear, the same fetch() call is run in dev versus production. On a whim, I then built a whole new Worker, HTTP based, copied and pasted the function that makes the fetch() call, and it works fine. Here's the worker, https://github.com/cfjedimaster/cloudflareworkers-demos/blob/main/scratchworker/src/index.js, and here is (virtually) the same worker as a HTTP service that runs just fine: https://github.com/cfjedimaster/cloudflareworkers-demos/blob/main/getincidents/src/index.js As I said, if I test locally, it's perfect.
GitHub
cloudflareworkers-demos/getincidents/src/index.js at main · cfjedim...
Repository for CF Workers demos/examples/etc. Contribute to cfjedimaster/cloudflareworkers-demos development by creating an account on GitHub.
2 Replies
James
James3mo ago
If I hit the URL in your Worker, https://lafayette911.org/WebService1.asmx/getCurrentTrafficConditions, my request just times out. Is it possible that this API you're hitting isn't always available? Or perhaps not available in certain parts of the world, etc.?
Raymond Camden
Raymond CamdenOP3mo ago
the service only responds to POST requests, so that's expected
Want results from more Discord servers?
Add your server