fix: preserve plugin-registered internal hooks across gateway startup#26184
Closed
white-rm wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix: preserve plugin-registered internal hooks across gateway startup#26184white-rm wants to merge 1 commit intoopenclaw:mainfrom
white-rm wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Author
|
@steipete could u help me to review this pr? i think it's an useful suggestion |
Contributor
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.
Summary
Fixes #25859
Plugin hooks registered via
api.registerHook("message:received", ...)were visible inopenclaw hooks listbut never fired. The root cause is a startup ordering issue:loadGatewayPlugins()runs first — plugins register handlers into the internal hooksMapviaregisterInternalHook()startGatewaySidecars()runs later —clearInternalHooks()wipes all handlers, thenloadInternalHooks()only reloads directory-discovered hooks, not plugin-registered onesChanges
src/plugins/registry.ts: Store the handler reference inPluginHookRegistrationso it survives the clear cycle. AddreregisterPluginInternalHooks()helper that re-registers plugin hooks from the registry.src/gateway/server-startup.ts: CallreregisterPluginInternalHooks()afterclearInternalHooks()+loadInternalHooks()to restore plugin hooks. Log output now includes plugin hook count.Test plan
internal-hooks.test.tstests pass (29/29)api.registerHook("message:received", ...), restart gateway, send a message — hook should fireGreptile Summary
This PR fixes a startup ordering bug where plugin-registered internal hooks (via
api.registerHook()) were permanently lost during gateway initialization. The fix stores handler references in the plugin registry and re-registers them afterclearInternalHooks()wipes the internal hooksMap.Key changes:
handlerfield toPluginHookRegistrationtype to preserve the handler function referencereregisterPluginInternalHooks()helper iterates the plugin registry and re-registers all stored handlersreregisterPluginInternalHooks()after directory-based hook loading completesConfidence Score: 5/5
Parameters<typeof registerInternalHook>[1]for the handler type. The implementation follows the existing patterns and doesn't introduce new complexity.Last reviewed commit: 5704cb2
(4/5) You can add custom instructions or style guidelines for the agent here!