- My goal:Run Workflow that uploads data to mySQL server
- Issue: Occasionally, the workflow will have errors whilst running a code segment or getting data from SQL, reading
"<html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>nginx</center> </body> </html>."
Also, specifically in the code segments, occasionally a nonetype error will occur, and this occur because the loop that is getting data will return a similar error as the one listed above, but it lists out more information that I can not see as follows:
Error evaluating get_worksheets_loop (iteration 1): Error fetching data for get_worksheets_loop
response: <html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
error: Unexpected token '<', "<html>
<h"... is not valid JSON
- Steps I've taken to troubleshoot: Looked at the logs and confirmed that they are not from our server that the workflow is touching
- Additional info: We are on Retool cloud. The specific data is sensitive, so if it is needed, I am willing to share problematic and the normal cases privately.
HI @Daniel_Fleuranvil,
This is a a pretty common issue when working with external resources inside Retool Workflows — especially when looping or making repeated SQL/API calls.
What sort of error handling do you have in place?
On the bottom of each block you have some basic settings. This should help.
You can also add basic retry handling like:
let attempt = 0;
let result = null;
while (attempt < 3) {
try {
result = await get_data_from_sql.trigger();
if (result) break;
} catch (err) {
attempt++;
await new Promise(r => setTimeout(r, 1000 * attempt)); // Exponential backoff
}
}
return result;
Let me know if this helps and we can go from there.