openclaw - 💡(How to fix) Fix Hook cache not invalidated after plugin hot-reload — message_sending hooks silently stop firing

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

In deliver-C6YJ_kD0.js, the delivery pipeline evaluates hooks once per batch:

const hasMessageSendingHooks = hookRunner?.hasHooks("message_sending") ?? false;

After hot-reload, the hook runner's internal registry is stale. The old hooks are cleared but hasHooks() returns the cached result from before the reload.

Fix Action

Workaround

Plugin-side: re-register hooks after a setTimeout delay to survive the cache window. Applied in openclaw-wa-archive.

Code Example

14:39:55 [wa-archive] Using api.on (gateway ≤2026.4.x)
14:39:55 [wa-archive] Plugin loaded successfully

# No message_sending events from 14:39 to 16:28 despite ~10 outbound messages
# message_received (inbound) continued working fine
# reply_dispatch fired but with empty content (expected — claiming hook)

16:28:03 [wa-archive] message_sending fired: chat=+972547552872 ...
# Suddenly starts working again

---

const hasMessageSendingHooks = hookRunner?.hasHooks("message_sending") ?? false;
RAW_BUFFERClick to expand / collapse

Bug Summary

After a plugin hot-reload (e.g., gateway restart), the message_sending hook stops firing for outbound messages. The hook is re-registered by the plugin via api.on(), but the delivery pipeline's cached hasHooks("message_sending") returns false because the cache is not invalidated on reload.

Impact

Any plugin relying on message_sending to intercept/observe outbound messages will silently miss ALL messages after a hot-reload until something triggers a cache refresh (observed: ~2 hours gap).

Evidence

From gateway logs on 2026-05-30:

14:39:55 [wa-archive] Using api.on (gateway ≤2026.4.x)
14:39:55 [wa-archive] Plugin loaded successfully

# No message_sending events from 14:39 to 16:28 despite ~10 outbound messages
# message_received (inbound) continued working fine
# reply_dispatch fired but with empty content (expected — claiming hook)

16:28:03 [wa-archive] message_sending fired: chat=+972547552872 ...
# Suddenly starts working again

Root Cause

In deliver-C6YJ_kD0.js, the delivery pipeline evaluates hooks once per batch:

const hasMessageSendingHooks = hookRunner?.hasHooks("message_sending") ?? false;

After hot-reload, the hook runner's internal registry is stale. The old hooks are cleared but hasHooks() returns the cached result from before the reload.

Affected Hooks

  • message_sending (modifying hook via runModifyingHook) — confirmed broken
  • message_sent (void hook via runVoidHook) — likely same issue
  • reply_dispatch (claiming hook via runClaimingHook) — fires but is not designed for content capture

Expected Behavior

After a plugin hot-reload, hasHooks() should immediately reflect the newly registered hooks.

Workaround

Plugin-side: re-register hooks after a setTimeout delay to survive the cache window. Applied in openclaw-wa-archive.

Environment

  • OpenClaw version: 2026.4.22 (gateway ≤2026.4.x path)
  • Plugin: @0x5e/openclaw-wa-archive using api.on() registration
  • OS: macOS (arm64)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Hook cache not invalidated after plugin hot-reload — message_sending hooks silently stop firing