Skip to content

fix(claw-pilot): stopAccount before restart on config change (PILOT-188)#2

Merged
TeoSlayer merged 1 commit into
mainfrom
openclaw/pilot-188-20260528-112237
May 28, 2026
Merged

fix(claw-pilot): stopAccount before restart on config change (PILOT-188)#2
TeoSlayer merged 1 commit into
mainfrom
openclaw/pilot-188-20260528-112237

Conversation

@matthew-pilot

Copy link
Copy Markdown
Collaborator

What failed

onAccountConfigChanged in channel-plugin-api.ts stopped the transport but left the account in PilotLifecycle.accounts, so the subsequent startAll → startAccount call threw "already running". The error was caught by startAll and routed to scheduleRetry, 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 manual acct.transport.stop() in onAccountConfigChanged with stopAccount() so startAll can re-create the account cleanly.

Verification

  • npm run build (tsc): clean, no errors
  • npm test (vitest): 230/230 tests pass, 28 test files, 4.37s
  • 2 files changed, +14/−4 lines

Deferred

Bug 1 from the same ticket (handshakeTrustAutoApprove dead 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

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

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@matthew-pilot

Copy link
Copy Markdown
Collaborator Author

🦾 Matthew PR Check — #2 PILOT-188

Status

  • State: OPEN · MERGEABLE · CLEAN
  • CI: 4/4 green — plugin (Node) ✅, iOS/ClawChat ✅, codecov/patch ✅, Snyk ✅
  • Canary: N/A (claw-pilot is a plugin repo, no canary harness)
  • Jira: PILOT-188 — QA/IN-REVIEW · assigned Teodor Calin · last updated 11:25 UTC

Summary

2 files (+14/−4) — adds PilotLifecycle.stopAccount() (lifecycle.ts) and replaces the manual transport stop in onAccountConfigChanged (channel-plugin-api.ts). All CI green. No canary required.

@matthew-pilot

Copy link
Copy Markdown
Collaborator Author

🔍 Matthew PR Explain — #2 PILOT-188

What changed and why

plugin/src/channel-plugin-api.ts:138 — the onAccountConfigChanged handler previously called acct.transport.stop() directly, which stopped the transport but left the account entry in PilotLifecycle.accounts. When startAll re-ran and hit startAccount for the same accountId, it threw "already running" — the error was caught and routed to scheduleRetry, so live config changes (e.g. adding a peer to the allowlist) were silently lost until gateway restart.

The fix replaces that two-line manual stop with a single call to lifecycle.stopAccount(accountId), which correctly removes the account from the live map.

plugin/src/lifecycle.ts:278-291 — new stopAccount(accountId) method. Idempotent (early-returns if the account isn't found). Clears the drain timer, stops the pipeline, awaits transport stop, and then — critically — deletes the account from this.accounts in a finally block. This ensures the map is always cleaned up even if one of the stop steps throws.

Diff summary: 2 files, +14/−4 lines. No new dependencies, no API surface change.

@TeoSlayer TeoSlayer merged commit 65d08ef into main May 28, 2026
4 checks passed
@TeoSlayer TeoSlayer deleted the openclaw/pilot-188-20260528-112237 branch May 28, 2026 16:57
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.

2 participants