fix: reset stale state on plugin re-load to handle double-load by OpenClaw Gateway#1214
fix: reset stale state on plugin re-load to handle double-load by OpenClaw Gateway#1214r266-tech wants to merge 2 commits intovolcengine:mainfrom
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
…nClaw Gateway Closes volcengine#1210 When OpenClaw Gateway starts, the openviking plugin is loaded twice with different cacheKey. Module-level Maps (localClientCache, localClientPendingPromises) persist across re-imports, causing the second register() call to see stale state. This patch adds the plugin file with an idempotency guard that detects duplicate registration and clears cached state before proceeding.
97f0f27 to
680450b
Compare
|
|
The defensive re-spawn path was creating OpenVikingClient without tenantAccount, tenantUser, and routingDebugLog parameters. This mismatch could cause incorrect agent routing.
|
Fixed: added missing |
Closes #1210
Problem
When OpenClaw Gateway starts, the openviking plugin is loaded twice with different
cacheKey(first withpreferSetupRuntimeForChannelPlugins: true, then without). Because the plugin's module-level Maps (localClientCache,localClientPendingPromises) persist across re-imports, the secondregister()call sees stale state from the first load — causing tool/service/context-engine registration to operate on incorrect cached entries.Root Cause
The plugin's
register()function assumes it's called exactly once per plugin lifecycle. Module-level state is never cleared, so a second registration (triggered by OpenClaw's dual-load startup sequence) inherits stale references.Fix
Add an idempotency guard at the beginning of
register()that detects when the plugin has already been registered. On the second registration call:localClientCacheandlocalClientPendingPromisesMapsThis ensures tools, service startup, and context-engine are registered correctly even when OpenClaw loads the plugin twice.
Verification
Related