openclaw - ✅(Solved) Fix Internal hooks re-registered on every reload cycle without deduplication [1 pull requests, 1 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#58594Fetched 2026-04-08 02:00:31
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
cross-referenced ×2commented ×1referenced ×1

Fix Action

Fix / Workaround

The internal hooks loader re-registers hook handlers on every periodic reload cycle without deduplication. After N reload cycles, the same hook fires N times on its lifecycle event. Workaround: dedup guard in handler. See openclaw-vault for full details.

PR fix notes

PR #58991: fix(hooks): deduplicate internal hook handlers on config reload

Description (problem / solution / changelog)

Summary

  • Add deduplication guard in registerInternalHook() to prevent the same handler from being pushed multiple times during periodic config reload cycles
  • After N reload cycles, previously the same hook would fire N times; now it fires exactly once

Details

registerInternalHook unconditionally pushes handlers to the array without checking for duplicates. When the config reloader re-runs registration code on every cycle, handlers accumulate. The fix adds an includes() check before push(), consistent with the indexOf() pattern already used by unregisterInternalHook.

Fixes #58594

Test plan

  • Verify hooks fire exactly once after multiple config reload cycles
  • Verify unregisterInternalHook still works correctly
  • Verify new handler registrations for different event keys still work

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Changed files

  • src/hooks/internal-hooks.ts (modified, +7/-1)
RAW_BUFFERClick to expand / collapse

The internal hooks loader re-registers hook handlers on every periodic reload cycle without deduplication. After N reload cycles, the same hook fires N times on its lifecycle event. Workaround: dedup guard in handler. See openclaw-vault for full details.

extent analysis

TL;DR

Implement a deduplication guard in the hook handler to prevent duplicate registrations.

Guidance

  • Identify the periodic reload cycle and hook registration points to understand where deduplication is needed.
  • Implement a deduplication mechanism, such as a unique identifier or a set data structure, to keep track of registered hook handlers.
  • Verify the fix by checking if the hook fires only once per lifecycle event after multiple reload cycles.
  • Review the openclaw-vault implementation for a potential reference or guidance on implementing the deduplication guard.

Example

No explicit code example is provided due to the lack of specific implementation details in the issue.

Notes

The provided workaround suggests that a deduplication guard in the handler is necessary, but the exact implementation may vary depending on the specific use case and requirements.

Recommendation

Apply workaround: Implement a deduplication guard in the hook handler, as this is the suggested solution in the issue and no fixed version is mentioned.

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 - ✅(Solved) Fix Internal hooks re-registered on every reload cycle without deduplication [1 pull requests, 1 comments, 2 participants]