We have updated our wrangler’s to version 3 and are getting strange errors when called an external api (Contentstack), the wrangler code can be seen in the below image. We try the call three times with a timestamp param before giving up and sometimes that works. The thing is we’ve never been able to get the API to fail testing it locally and so are wondering if there is something we should be doing differently in the wrangler when fetching data?
The log when we get these errors can also be seen below, as you can see we seem to be getting an empty string response from the fetch call to the API.
Given “Could not parse” message that is logged, and the fact that is in a try...catch, resp is not valid JSON. As this is logged, and there is nothing showing, I might suggest resp === null.
If you curl the url that is logged from such an event, do you get a non-null response?
Thanks for the response. Yep, not using curl but hitting it in Postman gives us the expected response, and sometimes the second or third call in the worker works successfully. For example that log shown worked on the second call, same API. There are also multiple successful responses on the first call to the API. I’m hoping to have a way to figure out if the issue is in the worker code or at the API’s end.
Does it happen when there is a number of calls in quick succession?
Or does it normally happen after a period of inactivity?
Perhaps log is response status code as well. If not a 2xx that could provide more information.
@ransom No resolution yet, working with API provider to hopefully find out if the failing calls are making it to their end or if something is going on at the wrangler end. Will update this ticket once a resolution is found.