Skip to content

Arm cron triggers once per process, not once per plugin registration - #54

Merged
pallaoro merged 1 commit into
mainfrom
fix/scheduler-reregister-guard
Sep 16, 2026
Merged

pallaoro merged 1 commit into
mainfrom
fix/scheduler-reregister-guard

Conversation

@pallaoro

Copy link
Copy Markdown
Member

Problem

OpenClaw calls a plugin's register() repeatedly inside one gateway process (config and agent reloads). ClawFlow built and started a new TriggerScheduler on each call without stopping the previous one, so each cron trigger was armed N times. On a customer box that had reloaded four times, the 08:00 digest flow started four instances within 43 ms and delivered four identical WhatsApp messages. A fleet audit found 2 to 14 armed schedulers per OpenClaw box.

Fix

Keep the live scheduler at module scope (same pattern as activeServer in serve.ts) and stop it before arming the replacement. Re-registration still refreshes config and runner.

Test

tests/plugin-reregister.test.ts registers twice on one workspace and asserts the trigger is armed on exactly the replacement scheduler.

Version 1.6.1 → 1.6.2.

OpenClaw runs a plugin's register() again on every config or agent reload
inside the same gateway process. Each call built a new TriggerScheduler
and started it without stopping the previous one, so every cron trigger
fired once per registration: a box that had reloaded four times ran its
08:00 flow four times in the same second, and delivered four digests.

Keep the live scheduler at module scope, the way serve.ts already keeps
activeServer, and stop it before arming its replacement. The replacement
still picks up the latest config and runner.

Fleet audit on 2026-09-16 found 2 to 14 armed schedulers per OpenClaw box.
@pallaoro
pallaoro merged commit 1fd4ebc into main Sep 16, 2026
1 check passed
@pallaoro
pallaoro deleted the fix/scheduler-reregister-guard branch September 16, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant