fix(TimerMgr): cancel existing timer before creating a new one

This commit is contained in:
Christian Weimann
2025-01-13 08:59:18 +01:00
parent 4a7185a1a5
commit fa635f46d9

View File

@@ -11,8 +11,7 @@ class TimerMgr {
create(id, timeout, func, ...params) { create(id, timeout, func, ...params) {
if (this.hasTimer(id)) { if (this.hasTimer(id)) {
log.error(`Timer with id ${id} already exists`); this.cancel(id);
return;
} }
log.debug("Create timer with id " + id); log.debug("Create timer with id " + id);
this.#timers[id] = actions.ScriptExecution.createTimer(id, timeout, func, ...params); this.#timers[id] = actions.ScriptExecution.createTimer(id, timeout, func, ...params);