Repository navigation
Arm cron triggers once per process, not once per plugin registration - #54
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
OpenClaw calls a plugin's
register()repeatedly inside one gateway process (config and agent reloads). ClawFlow built and started a newTriggerScheduleron 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
activeServerinserve.ts) and stop it before arming the replacement. Re-registration still refreshes config and runner.Test
tests/plugin-reregister.test.tsregisters twice on one workspace and asserts the trigger is armed on exactly the replacement scheduler.Version 1.6.1 → 1.6.2.