Site Monitoring! Awesome. I added logging to the fetch method. It hits the catch block, but just still says “Error” in the site monitoring. No message, no error code.
async function post(url, body){
let api_key = await getSecret(API_KEY_ID);
var headers = {
'Content-Type':'application/json',
'Content-Length': JSON.stringify(body).length.toString(),
'x-api-key': api_key
};
return fetch(url,
{
method: "post",
headers: headers,
body: JSON.stringify(body)
}).then(response => {
if (response.ok){
return response.json()
}
else{
Promise.reject("Error during post")
}
})
.catch(error => {
console.log(error.message)
Promise.reject("Exception during post")
})
}
I checked the usual suspects. Url, API key, request body, all seemingly in check. The failed attempt is always random. So like I mentioned, the loop will only run a max of 4 times. Sometimes it’s the first attempt, sometimes the last. And sometimes I can’t get it to happen for 100 tries and then I can’t get it to stop happening after that.
Apologies, here is the rest of the code execution path. First backend module simply creates the body, and then passes along to the api module.
export async function getDataTreeCounts(buckets, data_tree_filters, user_id){
const body = {"user_id": user_id, "buckets": buckets, "data_tree_filters": data_tree_filters}
return await data_tree_counts("/getCounts", body)
}
export function data_tree_counts(endpoint, body){
const url = base_data_tree_count_url + endpoint
return post(url, body)
}
No collection data. All of the data is coming from the external API. Most of the site’s core is outside of Wix. This code is just supposed to pull in some meta data in a loop (in order to get around the 14 second backend timeout limit).
Sorry for the long post. Thank you again for your time and interest in this. Super fascinating bug eh?!
-Ryan