fix(claw-pilot): stopAccount before restart on config change (PILOT-188)#2
Conversation
onAccountConfigChanged stopped the transport but left the account in PilotLifecycle.accounts, so the subsequent startAll → startAccount call threw "already running". The error was caught and routed to scheduleRetry, causing live config changes to be silently lost until gateway restart. Added PilotLifecycle.stopAccount() that stops transport + pipeline + drainTimer and removes the account from the map in a single idempotent operation. Replaced the manual transport.stop() in onAccountConfigChanged with stopAccount(). Note: Bug 1 (handshakeTrustAutoApprove dead config) confirmed but deferred — removing the flag touches 5 files (types, resolver, schema, 3 test files). Operator should split to a follow-up or handle manually. Closes PILOT-188
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🦾 Matthew PR Check — #2 PILOT-188Status
Summary2 files (+14/−4) — adds |
🔍 Matthew PR Explain — #2 PILOT-188What changed and why
The fix replaces that two-line manual stop with a single call to
Diff summary: 2 files, +14/−4 lines. No new dependencies, no API surface change. |
What failed
onAccountConfigChangedinchannel-plugin-api.tsstopped the transport but left the account inPilotLifecycle.accounts, so the subsequentstartAll → startAccountcall threw "already running". The error was caught bystartAlland routed toscheduleRetry, causing live config changes (e.g. adding a peer to the allowlist) to be silently lost until the gateway restarted.Why this fix
Added
PilotLifecycle.stopAccount(accountId)— a single idempotent method that stops the transport + pipeline + drain timer, then removes the account from the map. Replaced the manualacct.transport.stop()inonAccountConfigChangedwithstopAccount()sostartAllcan re-create the account cleanly.Verification
npm run build(tsc): clean, no errorsnpm test(vitest): 230/230 tests pass, 28 test files, 4.37sDeferred
Bug 1 from the same ticket (
handshakeTrustAutoApprovedead config — defined in schema but never consumed) is confirmed but not addressed here. Removing it touches 5 files (config.ts, openclaw.plugin.json, 3 test files) — the operator should split it to a follow-up or handle manually.Closes PILOT-188