Skip to content

Commit efd10a6

Browse files
committed
fix: register retry with Map + resetRegistration clear (#448)
1 parent 0988a46 commit efd10a6

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,10 +1615,14 @@ const pluginVersion = getPluginVersion();
16151615
// Plugin Definition
16161616
// ============================================================================
16171617

1618-
// WeakSet keyed by API instance — each distinct API object tracks its own initialized state.
1619-
// Using WeakSet instead of a module-level boolean avoids the "second register() call skips
1620-
// hook/tool registration for the new API instance" regression that rwmjhb identified.
1621-
const _registeredApis = new WeakSet<OpenClawPluginApi>();
1618+
// Map keyed by API instance — each distinct API object tracks its own initialized state.
1619+
// Using Map instead of WeakSet allows tracking per-instance state AND enables clear() for reset.
1620+
const _registeredApis = new Map<OpenClawPluginApi, boolean>();
1621+
1622+
// Helper for tests to check registered APIs
1623+
export function _getRegisteredApisForTest(): Map<OpenClawPluginApi, boolean> {
1624+
return _registeredApis;
1625+
}
16221626

16231627
const memoryLanceDBProPlugin = {
16241628
id: "memory-lancedb-pro",
@@ -1633,7 +1637,7 @@ const memoryLanceDBProPlugin = {
16331637
api.logger.debug?.("memory-lancedb-pro: register() called again — skipping re-init (idempotent)");
16341638
return;
16351639
}
1636-
_registeredApis.add(api);
1640+
// Note: Map.set(api, true) is called AFTER successful init in try block
16371641

16381642
// Parse and validate configuration
16391643
const config = parsePluginConfig(api.pluginConfig);

0 commit comments

Comments
 (0)