cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Nested repeat action retried within an error block using incorrect indices

jason1
Deputy Chef I
Deputy Chef I

I believe I've uncovered a rather serious bug. Let's say I have a repeat action and if an error occurs during an iteration, I want to catch it, wait X seconds, then retry the whole repeat action again.


Simple Ruby program that demonstrates this:



Output: [0, 1, 2, 3, 4]


Here's the recipe version in Workato: https://app.workato.com/recipes/1443583?st=ff6418


This recipe outputs [2, 3, 4], which is not correct. What I would expect is for the entire loop to repeat from index 0 on every attempt. Note that the list and repeat helper list are created anew per each attempt. However, it appears as if the loop is continuing at a previously stored offset.


This has produced serious production bugs for us. Can someone explain if my assumptions here are incorrect or if I've built the recipe logic incorrectly?





7 REPLIES 7

mroldanvega
Executive Chef I
Executive Chef I

Have you tried putting the error monitor outside the loop?

In order to retry the entire loop you would need to monitor the whole loop block.

Hi, thanks for the reply! There are 2 loops here. The outer loop is what controls the re-attempts and the inner loop is what's causing the issue. The entire inner loop is wrapped in a monitor block, which means it should be repeating in full each time. Is this what you mean?

mroldanvega
Executive Chef I
Executive Chef I

Yes, that is what I meant

I tried your recipe, adding 1 list and seems like the recipe keeps track of the index and it retries the loop from that index, so the offset is correct. No?




BTW - curious to know why you use the Ruby 'sleep' function instead of the Retry on the 'error' block



jason1
Deputy Chef I
Deputy Chef I

Right, so I guess my question is why is it maintaining an offset? It should be recreating the list and the repeat helper list each time a new retry is executed. Ideally, this means the index is always reset to 0. If you refresh the recipe I shared, you should be able to see this.


In terms of why I use "sleep", I need more control of how much time I can "wait" per each successive runs (ex: to do something like exponential backoff). The error block retry only gives you a fixed number of seconds each retry. However, in this simple example, I could have used the error block retry.