- My goal: To terminate a workflow that's been Pending for HOURS
- Issue: Life can be scary, but when will it end? Some workflows die way too soon. This one won't respond to Terminate Run clicks.
- Steps I've taken to troubleshoot: I've been experimenting with different minor tweeks to make my workflow succeed. I joined an array of emails into a string in my last attempt.
- Additional info: (Cloud or Self-hosted, Screenshots)
just curious (sorry if this is like asking "is it plugged in?" lol), but did you accidently set up an infinite loop? I mean, I'd have assumed it would have ran out of memory by now if so, but
who knows maybe you're somehow freeing memory while inside the loop? figured it was worth double checking ![]()
I think it's pretty obvious it's in an infinite loop. I'm surprised that checking the interface for a termination button click by retool never happens though.
I'm looping through an array of just two objects. In the loop I'm submitting info to PBI, waiting 90 seconds, then checking for the completed report, and if necessary, waiting and checking again, then getting the finished report, attaching it to an email, and submitting it to MailGun. We've done lots of tests and this is the first time it's happened.
Hi @rlhane.2_19635,
I've had this happen a couple of times. Sometimes the process takes a while to stop and it is definitely not instant. If you can't get it to stop, reach out to the retool team, and they can help out in the back end. @Jack_T helped me stop mine in the past and helped diagnose. @Darren and @Tess are never very far as well.
If you show us more of your workflow, we might be able to help break it down with you. The more screenshots the better!
The workflow is launched by the app via a query attached to a submit button. The outer shell of it looks like this...
The export function called in the loop is the meat of it. It starts a PBI report export, polls up to 6 times, exports the report, attaches it to an email and submits it to Mailgun, then waits sufficiently to stay within our PBI licensing agreement, so when run again, we dont get an error.
Within that we have the poll function that checks PBI for the completed report.
Nothing in your screenshots alone indicates an infinite loop. To be safe though, you could consider using JS-based looping for better control.
Adding console.log() in your JavaScript blocks will help you see better how your workflow is functioning and will show up in your Run History panel.
Here's a basic JS Loop with iteration logging
let maxTries = 20;
for (let i = 1; i <= maxTries; i++) {
console.log(`Iteration #${i}, checking export status...`);
const status = await checkExport(); // function that queries API
console.log('Export status:', status);
if (status === 'Succeeded') {
console.log('Export completed; exiting loop.');
break;
}
await new Promise(r => setTimeout(r, 5000)); // delay
}
console.log('Loop finished or timed out after', maxTries, 'tries');
return { success: status === 'Succeeded', attempts: i };
These are steps I would take but it still could be bug. I'm sure one of the Retool team members could have a look for you if it persists.
Hey @rlhane.2_19635!
It looks like you're self-hosted, so I don't have access to your backend. Here are a few things you can try:
- Check how your Temporal is deployed.
(We've seen cases where self-hosted Temporal instances get stuck in a "pending" state, often due to issues like CPU limits being hit. If the workflow gets stuck again, please check the health status of your Temporal instance at that time.) - Review your container logs for any error messages.
Let me know what you find, and feel free to share any logs or health info from Temporal if it happens again!
Hi ChiEn, Thanks for responding. I'm doing this dev work on our .retool.com instance. We were on self-hosted for a while, but when the system admins realized the burden and responsibility, they agreed to change us back. Your insights would be appreciated. -Ron
HI Shawn, This is something I've never done. Where would I incorporate this block in my workflow? I guess it's a replacement for pollFunction except it uses the checkExport PBI API call inside pollFunction.
You can replace the pollFunction block with a JavaScript code block that performs the polling loop, directly calling your workflow function block (e.g. checkExportFunction) via await.
Add a JavaScript code block in your workflow in place of the pollFunction step.
Sample code structure:
let maxTries = 3;
let status = '';
for (let i = 1; i <= maxTries; i++) {
console.log(`Iteration #${i}`);
const resp = await checkExportFunction('foo', 'bar');
console.log('Full response:', resp);
status = resp?.status;
console.log('Status value:', status);
if (status === 'Succeeded') {
console.log('✅ Export succeeded, exiting loop.');
return { success: true, attempts: i, finalStatus: status };
}
await new Promise(resolve => setTimeout(resolve, 1000)); // 1s wait for test
}
return { success: false, attempts: maxTries, finalStatus: status };
Does this make sense?
Thanks for clarifying @rlhane.2_19635 that you are on Cloud, can you provide your workflows run ID? I will see what I can do!
Where do I find it?
Hey Shawn, made a single-step function that contains the PBI API call to check for export ready and used it in an await in the following update to the workflow. It hates it. Can you really treat a workflow function like a js function? what do I need to change? Here it is...
@rlhane.2_19635 Go to run history in your workflows, you should see the run ID on your browser URL, copy that and paste it here, thank you!
Hey, sorry I'll be out for a few hours but can look when I get back!
Hi ChiEn,
I see runId=
01983da7-cf72-77ac-8b1c-492cd2b1fd70
THANKS!
Hi @rlhane.2_19635,
Can you try v1.0/myorg/groups/{{ workspaceId }}/reports/{{ reportId }}/exports/{{ exportId }}? You shouldn't need params. as you already have them when you call the function.
Hi @rlhane.2_19635, just checking in, what's the status of your workflows on your end? I took a look and the workflow run shows as completed from our side.
Yes. It is ended now. Thx!
Can you tell me anything about the cycling it was doing? I don't see why it was in an infinite loop, but it wouldn't even respond to a Terminate Run request. I need to correct this and get it stable. Thanks!





