Usually you can add retry/delay for any node in n8n workflow. It can be done in node Settings tab:
But 5000 ms or 5 s is the maximum value for delay and max tries value is limited to 5. And you sometimes need more. For example, some APIs has throttling and you want to wait 1 minutes before next try. In this case you need some another approach.
Let's start with Set node and define our initial parameters for retry/delay:
After that we add some target node which we want to apply retry/delay approach to - in this example it's HTTP Request node:
It should be configured to continue on error using error output:
Then add another Set node to error output, it will decrement tries number:
After that we just need to add If node to check if we still have tries remaining:
And finally add Wait node to False output of If node and connect to input of target node:
Don't forget to change Wait Amount to our value from Set node:
True output of If node is active when error still happens after all tries. So it can be connected with some fallback or Stop And Error node. And Success output of target node is active when one of the tries is successful and we get the data.
We can also increment delay for the next try by some fixed amount or exponentially.
Let's check this approach by executing our example workflow:
You can see that target node was called exactly 6 times as we specified in the first Set node.
You can find the template for the described approach here.
No comments:
Post a Comment