Repository navigation
fix(setup): pairing fails with "gateway starting" when setup proceeds before the Gateway finishes startup - #1743
Conversation
The WSL health gate polled `/`, which is the Control UI SPA. It answers once dispatch is ready but before startup sidecars settle, while the gateway still rejects operator WebSocket connects with 1013 "gateway starting". With Control UI disabled it returns 404 and the gate only timed out. - StartGatewayStep polls GET /startupz inside WSL: 200 JSON = started, 503 JSON = still starting (pendingReason logged and reported on timeout). Gateways before 2026.8.1 fall back to the legacy root check. - WindowsGatewayReachability repeats GET /startupz from Windows on the pairing URL before operator/node pairing, waiting up to HealthTimeoutSeconds on 503. Transport errors still fail fast; non-probe answers (older gateways, remote ingress) count as reachable.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR waits for Gateway startup completion before setup proceeds to pairing, while retaining compatibility with older Gateways. Example: Gateway 2026.10.4 returns HTTP 503 with pendingReason startup-sidecars while its Control UI already returns HTTP 200.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a startup-readiness bug still present on main, and inspection found no definite introduced code defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe SetupEngine starts the managed WSL Gateway, checks readiness inside WSL and reachability from Windows, then passes through listener-ownership verification before authenticated operator and node pairing. flowchart TD
A[Setup pipeline] --> B[Start managed WSL Gateway]
B --> C[WSL startup probe]
C --> D[Windows startup probe]
D --> E[Listener ownership verification]
E --> F[Operator and node pairing]
Technical reviewBest possible solution: Keep startup readiness in the existing setup owners while preserving legacy reachability and independent credential-authorization gates. Do we have a high-confidence way to reproduce the issue? Main's root-page success condition can precede the upstream startup admission condition; the supplied real-Gateway logs independently demonstrate that pending startup state, but this review ran no target code. Is this the best way to solve the issue? Using the Gateway's existing startup contract in both readiness owners addresses the premature gate directly, preserves older-Gateway fallback, and leaves authentication and listener ownership with their existing owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9ac0169aa0f1. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 16, 2026, 2:42 PM ET / 18:42 UTC. |
Resolve conflicts with openclaw#1743 (wait for /startupz before pairing): keep its startup-probe polling loop and apply the 30s, env-overridable per-probe timeout from this branch to each probe. Keep both test sets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Fixes: WSL setup can move on to operator pairing before the Gateway has finished starting, so the first operator connect is rejected with "gateway starting" (WS close 1013) and fails. With Control UI disabled, setup instead times out after 90s.
User Impact
User impact: setup waits until the Gateway reports that startup is complete before pairing, and a startup timeout now says what the Gateway was still waiting on (for example
pendingReason: startup-sidecars).Why This Change Was Made
The setup health gate polled
/, the Control UI page. That page answers once request dispatch is ready, before plugins and channels finish loading, while the Gateway still refuses operator connects. It returns 404 when Control UI is disabled. The Gateway's documented startup probe isGET /startupz: 200 JSON once startup is complete (the same condition it uses to admit operator connects), 503 JSON with apendingReasonwhile pending. The Gateway's ownopenclaw gateway restartalready waits on it.StartGatewaySteppolls/startupzinside WSL (curl, so the request always reaches the distro's own listener). Gateways before 2026.8.1 do not serve the probe and fall back to the old root check.WindowsGatewayReachability(runs before operator and node pairing) repeatsGET /startupzfrom Windows on the URL Companion pairs through, waiting up toHealthTimeoutSecondson 503. Connection errors still fail fast. Any other HTTP answer (older Gateway, Tailscale remote ingress) still counts as reachable. The port-ownership check still runs before any credential is sent.Evidence
Real WSL Gateway 2026.10.4 via
scripts/validate-mxc-e2e.ps1; the setup log shows the Gateway mid-startup and both new checks:New tests:
/startupzis 503 even if/answers 200 (fails on the old check);startup-sidecars;pendingReasonon timeout, and accepts non-probe answers.Change Type
Scope
winnodeRequired proof pools
windows-wsl-gateway-e2e: changes the WSL setup start gate and the pre-pairing reachability check.windows-wsl-mxc: the setup/connect path is part of the required MXC E2E validation.Validation
./build.ps1: all builds succeededdotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore: 2339 passed, 1 skippeddotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 4313 passed, 36 skippeddotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 4083 passed.\scripts\validate-mxc-e2e.ps1 -NoBuild: failed (11 passed, 7 failed), see belowReal Behavior Proof
.\scripts\validate-mxc-e2e.ps1 -NoBuildstartup-sidecars, then 200. The Windows-side probe returned 200 before pairing.Loopback port <port> listener verification failed: wslrelay (PID <pid>): WSL relay Authenticode verification failed (Unsigned). That host rejects its unsignedwslrelaybinary; this PR does not touch that check. Because of it, operator/node pairing, the "no 1013 during pairing" observation, and the three required MXC proofs did not run on this host. Rubber-duck review was not run.Security Impact
Yes, explain the risk and mitigation: the probes call the Gateway's unauthenticated/startupzroute (inside WSL and from Windows) instead of/and/healthz. They carry no credentials. The response body is sanitized and capped at 512 characters before logging, and the port-ownership check still gates every credential handoff.Compatibility and Migration
Review Conversations