Blockly timer cancel does not work correctly

Hi Stefan @stefan.hoehn ,

not sure if I use your timer blockly in a wrong way, but the resulting code to cancel a timer does not work:


leads to the following error message:

 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: TypeError: Cannot read property "cancel" from null

It needs to be


Can you please post an image of the blocks as well?

:man_facepalming: If you trigger the rule twice in MainUI by “Run Now” button, the rule gets (for any reason) updated which deletes the private cache and was misleading me.
All good with your code.
Sorry for the inconvenience.

yes, that is “intended”. a new rule instance is being completely recreated. Just as a heads up: if you have triggered an “endless” timer loop that you want to stop, you won’t be able to do that because you have no reference to that timer anymore (even though the timer is named the same way). You only get rid of it by restarting the server…

Though, this is only an issue during development…

Hope that helps.

Do you mean a timer with a loop and maybe a sleep that never finishes or do you mean a timer that reschedules itself?

If the latter, my understanding is that before the cache gets cleaned, core will cancel any timers it finds there for you.