Question on side effects of rule retrigger

From the documentation, waits are cancelled when a rule is re-triggered. However, according to my tests, it's not just the wait that is cancelled, but the rest of that rule instance's execution flow. It seems the actions that follow the cancelled wait do not proceed. Is this correct ?

One exception I have come across is a wait inside of a repeat. It seems when the rule is retriggered, the wait inside the repeat is cancelled, along with the other actions inside the repeat, but the repeat itself continues. Is this correct ? Are there other exceptions ?

(I'm aware I can add a Cancel Timed Actions at the top of the rule to ensure a re-trigger cancels everything, including repeats. A blunt instrument. BTW it's a bit confusing to select "Cancel Rule Timers" in the combo box only to see the action renamed to "Cancel Timed Actions" in the actions list.)

Correct, Waits and all subsequent actions are canceled when the rule is re-triggered.

Correct. Another way to cancel a Repeat is to make it stoppable while having the first action of your rule
Stop Repeating Actions

4 Likes

Thank you for confirming. @bertabcd1234 might it be helpful to add the "all subsequent actions" to the docs, e.g. to the "Cancellation of Waits" section ?

Thanks - forgot about that one.

@bravenel when debugging a rule, I sometimes find it difficult to figure out which execution flow (or rule instance) is which in the logs, so I have been avoiding repeats and even waits as much as I can. Would it be possible to tag the logs with something that uniquely identifies each execution flow ?

1 Like

What if you turned on logging for trigger events? That could indicate the point where the changeover occurs...

1 Like

It's actually not really possible. Such information would have to be stored in the rule state, but there is only one state for all instances of a rule. Hence, there is no way to distinguish one instance from another in the code.

If you have all logging turned on, you can follow from the Triggered event through the actions in a straight forward manner.

3 Likes

Thanks, useful to know.

In the (somewhat contrived) test I wrote to understand why one of my rules is failing, it was actually not so straightforward, as I think I ended up with multiple repeat loops in parallel.

This is certainly possible if care isn't taken. Use a Required Expression for Private Boolean true. Set PB false as first action, and set it to true as last action. That will prevent multiple parallel repeat loops.

1 Like

I use this pattern in a lot of rules. To the point where I wonder if it could be provided as a rule setting instead of having to set it up explicitly ?

2 Likes

It's problematic, as rules can have multiple exits, not just the end of the actions. It's not entirely a one-size-fits-all situation. So adding a feature would also add lots of caveats, and that would lead to even more confusion, imo.

3 Likes