Skip to content

fix(openclaw): add WeakSet registration guard keyed by API instance#1409

Merged
nicoloboschi merged 1 commit intovectorize-io:mainfrom
vernmic:fix/weakset-guard
May 4, 2026
Merged

fix(openclaw): add WeakSet registration guard keyed by API instance#1409
nicoloboschi merged 1 commit intovectorize-io:mainfrom
vernmic:fix/weakset-guard

Conversation

@vernmic
Copy link
Copy Markdown
Contributor

@vernmic vernmic commented May 4, 2026

Adds a WeakSet guard at the top of the plugin entry function. If the same api object is passed again (registry churn), the entry function exits immediately without re-registering hooks or event listeners.

WeakSet is keyed by object identity, not a module-level boolean. A new api object (e.g. after a registry migration) will have a different reference and pass through unconditionally -- this does not reintroduce the bug fixed by #1029 where a module-level boolean blocked new registries from ever getting hooks.

Old api objects that are no longer referenced are garbage-collected by the WeakSet (no memory leak).

Closes: #1404
Refs: #1029

Adds a WeakSet<MoltbotPluginAPI> guard at the top of the plugin entry function.
If the same api object is passed again (registry churn), the entry function exits
immediately without re-registering hooks or event listeners.

WeakSet is keyed by object identity, not a module-level boolean. A new api object
(e.g. after a registry migration) will have a different reference and pass through
unconditionally -- this does not reintroduce the bug fixed by vectorize-io#1029 where a
module-level boolean blocked new registries from ever getting hooks.

Old api objects that are no longer referenced are garbage-collected by the WeakSet
(no memory leak).

Closes: vectorize-io#1404
Refs: vectorize-io#1029
@nicoloboschi nicoloboschi merged commit 0ce9f33 into vectorize-io:main May 4, 2026
liling pushed a commit to liling/hindsight that referenced this pull request May 5, 2026
…ectorize-io#1409)

Adds a WeakSet<MoltbotPluginAPI> guard at the top of the plugin entry function.
If the same api object is passed again (registry churn), the entry function exits
immediately without re-registering hooks or event listeners.

WeakSet is keyed by object identity, not a module-level boolean. A new api object
(e.g. after a registry migration) will have a different reference and pass through
unconditionally -- this does not reintroduce the bug fixed by vectorize-io#1029 where a
module-level boolean blocked new registries from ever getting hooks.

Old api objects that are no longer referenced are garbage-collected by the WeakSet
(no memory leak).

Closes: vectorize-io#1404
Refs: vectorize-io#1029
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.

fix(openclaw): hindsight-openclaw hooks fire multiple times per turn after registry rebuild or hot reload

2 participants