Skip to content

fix(setup): pairing fails with "gateway starting" when setup proceeds before the Gateway finishes startup - #1743

Merged
RomneyDa merged 1 commit into
openclaw:mainfrom
larroy:fix/gateway-startupz-probe
Oct 16, 2026
Merged

RomneyDa merged 1 commit into
openclaw:mainfrom
larroy:fix/gateway-startupz-probe

Conversation

@larroy

@larroy larroy commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

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 is GET /startupz: 200 JSON once startup is complete (the same condition it uses to admit operator connects), 503 JSON with a pendingReason while pending. The Gateway's own openclaw gateway restart already waits on it.

  • StartGatewayStep polls /startupz inside 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) repeats GET /startupz from Windows on the URL Companion pairs through, waiting up to HealthTimeoutSeconds on 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:

Gateway still starting (/startupz HTTP 503 {"ok":false,"status":"starting","version":"2026.10.4","uptimeMs":1549,"pendingReason":"startup-sidecars"})
Gateway startup probe reports started (/startupz HTTP 200)
Gateway startup probe from Windows reports started (/startupz HTTP 200)

New tests:

  • the WSL check keeps waiting while /startupz is 503 even if / answers 200 (fails on the old check);
  • a timeout reports startup-sidecars;
  • older gateways fall back to the root check;
  • the Windows check waits through 503, reports pendingReason on timeout, and accepts non-probe answers.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required 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 succeeded
  • dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore: 2339 passed, 1 skipped
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 4313 passed, 36 skipped
  • dotnet 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 below

Real Behavior Proof

  • Environment tested: Windows 10.0.28000 ARM64, fresh app-owned WSL distro (Ubuntu-24.04), OpenClaw Gateway 2026.10.4 from npm
  • PR head or commit tested: a6a0339
  • Exact steps or command run: .\scripts\validate-mxc-e2e.ps1 -NoBuild
  • Evidence after fix: setup log lines quoted under Evidence
  • Observed result: the WSL probe saw 503 startup-sidecars, then 200. The Windows-side probe returned 200 before pairing.
  • Screenshot or artifact links verified? N/A
  • Not verified or blocked: setup then stops at the existing port-ownership check, before any WebSocket connect: Loopback port <port> listener verification failed: wslrelay (PID <pid>): WSL relay Authenticode verification failed (Unsigned). That host rejects its unsigned wslrelay binary; 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

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • New or changed network calls? Yes
  • Command or tool execution surface changed? No
  • Data access scope changed? No
  • If any answer is Yes, explain the risk and mitigation: the probes call the Gateway's unauthenticated /startupz route (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

  • Backward compatible? Yes (Gateways before 2026.8.1 fall back to the previous root check)
  • Config or environment changes? No
  • Migration needed? No
  • If yes, list the exact upgrade steps:

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

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.
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Setup accepts the root-page response and attempts operator pairing, which can be rejected with WebSocket close 1013.
  • After: Setup waits until /startupz returns HTTP 200 before proceeding toward pairing.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch matches the upstream contract and has meaningful regression coverage, but the required native validation is incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: WSL setup can fail pairing while the Gateway is still starting, or time out despite a running Gateway when Control UI is disabled.
Reason: The maintainer-authored direction repairs the existing setup contract using an authoritative Gateway endpoint, with no new setting or public API.

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
Reviewed head: a6a0339bc7e5379fada7b0c998106a6155934af3

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Successful current-head operator/node pairing and strict MXC execution remain unverified; a failing-base test run and retained-state upgrade run were not supplied.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Barbara Kudiess: Raw commit b37307c adds src/OpenClaw.SetupEngine/StartGatewayStep.cs:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b37307cbd51f; files: src/OpenClaw.SetupEngine/StartGatewayStep.cs)
  • Karen: Raw commit 24263d3 adds src/OpenClaw.SetupEngine/StartGatewayStep.cs:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 24263d3b06c4; files: src/OpenClaw.SetupEngine/StartGatewayStep.cs)
  • Scott Hanselman: Raw commit 1977368 adds src/OpenClaw.SetupEngine/StartGatewayStep.cs:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 19773680ea84; files: src/OpenClaw.SetupEngine/StartGatewayStep.cs)

Review metrics

Metric Value Why it matters
Change distribution Production +136/-26; tests +158/-3; docs +15/-4 Growth covers both transport boundaries, startup diagnostics, and compatibility coverage without adding another production owner.

Labels

Label changes:

  • add P1: WSL setup can attempt pairing before Gateway startup completes or time out when Control UI is disabled, interrupting a core onboarding workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: WSL setup can attempt pairing before Gateway startup completes or time out when Control UI is disabled, interrupting a core onboarding workflow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the scoped native validation described in realBehaviorProof.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 16, 2026, 2:42 PM ET / 18:42 UTC.

@larroy larroy added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. and removed P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. P1 Urgent regression or broken agent/channel workflow affecting real users now. labels Oct 16, 2026
@RomneyDa
RomneyDa merged commit f9ce47d into openclaw:main Oct 16, 2026
30 checks passed
RomneyDa added a commit to larroy/openclaw-windows-node that referenced this pull request Oct 16, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants