I have a workflow triggered by a webhook. Because the system that sends the webhook can send tons at the same time and my workflow uses an API with a throttle limit, I added some random seconds to wait after receiving the webhook but before doing the workflow tasks. This is between 0 and 300 seconds (5 min).
Everything is executing, but the random wait time doesn’t seem to be doing anything. Here’s the timeline of an an example execution:
webhook called, execution of workflow starts at 13:01
Random wait time is 193 seconds, a little over 3 minutes
Sub-workflow, which is called by this webhook workflow, starts at 13:01 with it’s own execution id
Database update made by sub-workflow is made at 13:01 according to database
So it seems like the Wait node is not doing anything. I’ve used an Edit Fields/Set node to see the wait time in seconds used by the Wait node during an execution.
The example flow you provided I do not see any random actions taking place. The generate random seconds up to 300 seems to be a set node with no content (at least in the renderer on the forums).
I would recommend using a code node or just an inline expression in the wait node. Easy.
The example flow you provided I do not see any random actions taking place. The generate random seconds up to 300 seems to be a set node with no content (at least in the renderer on the forums).
I notice those nodes where empty and added this to my original post to show the javascript I’m using to generate the random number.
Fields to Set: wait_time_seconds = {{ Math.floor(Math.random() * 300) }}
I don’t know why those nodes were cleared when I downloaded the workflow.
Ah interesting. That should work. I’d say, unless need elsewhere, make that an inline expression on the wait node rather than pre-set. Or try not force cast it within the set node as a string, that could be the issue. It should be a number.
For clarity, I use the Set/Edit Fields node because I want each execution to save/include the value it waited. If you use this JavaScript directly in the Wait node, then there’s no way to know how long it waited in that particular execution.