Skip to content

fix(setup): bound Tailscale status read so WaitForExit can fire - #1267

Closed
SebTardif wants to merge 1 commit into
openclaw:mainfrom
SebTardif:fix/f002-tailscale-read-timeout
Closed

SebTardif wants to merge 1 commit into
openclaw:mainfrom
SebTardif:fix/f002-tailscale-read-timeout

Conversation

@SebTardif

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users turning on Tailscale during Companion setup would freeze the Capabilities page when tailscale.exe status --json hung or left stdout open. The 5 second wait never ran, because the UI blocked on StandardOutput.ReadToEnd() first. Setup then sat on "Checking Windows Tailscale" until the child exited or the operator killed the wizard.

Why This Change Was Made

The setup Tailscale status probe now waits for the child first, then drains leftover stdout with the remaining budget, and kills the process tree if either step times out. The 5 second bound is unchanged. This does not change Tailscale Serve install or the later preflight step that already uses CommandRunner.

User Impact

Operators can toggle Tailscale on the setup Capabilities page without the wizard hanging when the Windows Tailscale CLI is stuck. A failed or timed-out probe still shows that Windows Tailscale must be installed and signed in.

Evidence

Live dotnet run against a child that never exits (sleep 20), using the same ReadToEnd-before-WaitForExit order as setup, then the WaitForExit-first plus kill-tree order this patch uses:

$ cd /tmp/f002-tailscale-bound-proof && dotnet run
=== before: ReadToEnd then WaitForExit ===
ReadToEnd completed within 1500ms: False
elapsed_ms=1505
read_status=WaitingForActivation
child_exited=False

=== after: WaitForExit first, then leftover drain, kill tree ===
WaitForExit(400) returned: False
elapsed_ms=431
read_status=RanToCompletion
child_exited=True

Setup now calls BoundedProcessOutput.Read from RefreshWindowsTailscaleStatusAsync instead of ReadToEnd() before WaitForExit(5000).

Change Type

  • Bug fix

Scope

  • Setup or onboarding

Required proof pools

  • none: the hang is the setup Tailscale child-process wait/read. A hung child on this host is enough. No installer, WSL, or interactive WinUI host is required.

Validation

  • dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --filter FullyQualifiedName~BoundedProcessOutputTests
  • Red (unbounded Wait on stdout first): AwaitRedirectedOutput_ReturnsNullWhenStdoutNeverCloses failed after 3.19s (Assert.Same helper still Running)
  • Green (WaitForExit first, leftover drain, kill tree): 4 passed in 1.69s
  • dotnet format --verify-no-changes on the new helper and tests
  • WinUI project and ./build.ps1 were not run on this macOS host

Real behavior proof

  • Behavior or issue addressed: Setup Capabilities Tailscale probe blocked forever on ReadToEnd() so WaitForExit(5000) never ran when tailscale.exe hung or kept stdout open.

  • Real environment tested: macOS 26.6.2, Darwin, Node v26.7.0, .NET 10.0.400, branch fix/f002-tailscale-read-timeout at d92edb7c, invoked with dotnet run from /tmp/f002-tailscale-bound-proof.

  • Exact steps or command run after this patch:

    cd /tmp/f002-tailscale-bound-proof
    dotnet run
  • Evidence after fix: terminal output from the patched wait order:

    === after: WaitForExit first, then leftover drain, kill tree ===
    WaitForExit(400) returned: False
    elapsed_ms=431
    read_status=RanToCompletion
    child_exited=True
  • Observed result after fix: WaitForExit returned in 431ms, the hung child was killed, and the caller continued. The old ReadToEnd path was still waiting at 1505ms with the child alive.

  • What was not tested: Interactive Setup wizard on a Windows host against a real hung tailscale.exe.

Security Impact

  • New permissions or capabilities? (No)
  • Secrets or tokens handling changed? (No)
  • New or changed network calls? (No)
  • Command or tool execution surface changed? (No)
  • Data access scope changed? (No)

The probe still launches the same tailscale.exe status --json command. Only the wait and kill-on-timeout behavior changed.

Compatibility and Migration

  • Backward compatible? (Yes)
  • Config or environment changes? (No)
  • Migration needed? (No)

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.

Related: introduced in #967. #1168 bounds a different keepalive command-line drain and does not touch this setup probe.

Setup Capabilities called ReadToEnd() before WaitForExit(5000), so a
hung or pipe-blocked tailscale.exe never reached the timeout.

Wait for the child first, drain leftover stdout, and kill the process
tree when either step times out.

Signed-off-by: Sebastien Tardif <[email protected]>
@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 3, 2026, 1:39 AM ET / 05:39 UTC.

ClawSweeper review

What this changes

The PR replaces the setup Capabilities page’s unbounded Tailscale status-output read with a bounded process-output helper and focused tests.

Merge readiness

⛔ Blocked before merge - 5 items remain

This PR remains necessary because current main still performs the unbounded read, but it should not merge as written: its timeout path exceeds the claimed five-second bound. A collaborator’s explicitly maintained replacement, #1296, preserves the fix and addresses that defect with Windows proof; repository policy keeps this PR open until the replacement lands.

Priority: P2
Reviewed head: d92edb7c611d7f227121fa7e626a58c5f01a6b71

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The branch contains a focused anti-hang repair, but its deadline guarantee remains incomplete and direct Windows setup-path proof is absent.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The supplied macOS terminal trace demonstrates an analogous process pattern, but it does not exercise the current-head Windows Capabilities-page owner or a Windows Tailscale invocation; the maintained replacement supplies Windows production-entry proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The supplied macOS terminal trace demonstrates an analogous process pattern, but it does not exercise the current-head Windows Capabilities-page owner or a Windows Tailscale invocation; the maintained replacement supplies Windows production-entry proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Introduced timeout overrun: The introduced helper waits for process exit, then grants a minimum 250 ms drain even after the configured timeout is exhausted; its cleanup can also wait up to one second.
Focused test does not assert the configured deadline: The hung-process test passes a 400 ms timeout but accepts any duration up to two seconds, so it cannot protect the claimed one-deadline behavior.
Current main remains affected: The fetched default branch and latest release tag v2026.7.1-3 still call StandardOutput.ReadToEnd before WaitForExit(5000), so the requested behavior is not already implemented on main.
Findings 1 actionable finding [P2] Keep all probe cleanup within the five-second deadline
Security None None.

How this fits together

The setup Capabilities page runs the local Windows Tailscale status command to determine connection guidance. Its parsed result updates the setup UI and configuration preview.

flowchart LR
A[Capabilities page] --> B[Tailscale status command]
B --> C[Bounded output helper]
C --> D[Status parser]
D --> E[Setup guidance]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The supplied macOS terminal trace demonstrates an analogous process pattern, but it does not exercise the current-head Windows Capabilities-page owner or a Windows Tailscale invocation; the maintained replacement supplies Windows production-entry proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Keep all probe cleanup within the five-second deadline (P2) - The exit wait can consume the full five seconds, then Math.Max grants another 250 ms to drain and cleanup may wait another second. This contradicts the PR’s stated unchanged five-second bound; the maintained replacement already addresses it.
  • Resolve merge risk (P1) - Merging this branch can keep the setup probe busy beyond its stated five-second deadline during drain or cleanup.
  • Resolve merge risk (P1) - The local partial clone could not retrieve the replacement branch object because network name resolution was unavailable; replacement details are from the supplied maintainer comment and PR context.
  • Complete next step (P2) - Do not merge this branch. Land the maintained replacement at fix(setup): enforce one Tailscale probe deadline #1296, or port its one-deadline repair and Windows proof here.

Findings

  • [P2] Keep all probe cleanup within the five-second deadline — src/OpenClaw.SetupEngine/BoundedProcessOutput.cs:62
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch footprint production +109/-5, tests +132 Most of the patch adds a reusable process-lifecycle helper and its focused coverage for one setup probe.

Merge-risk options

Maintainer options:

  1. Use the maintained replacement (recommended)
    Land the replacement PR that preserves this fix and enforces one five-second deadline before closing this branch.
  2. Repair this branch instead
    Port the one-deadline drain and cleanup correction plus Windows proof into this branch before merge.

Technical review

Best possible solution:

Land the maintained replacement with one deadline across exit, drain, and cleanup, then close this original branch as superseded.

Do we have a high-confidence way to reproduce the issue?

Yes, from source. A process can consume the configured exit timeout and then receive additional drain and cleanup time, exceeding the stated deadline.

Is this the best way to solve the issue?

No. The maintained replacement applies one deadline across exit, drain, and cleanup, avoiding this branch’s extra grace periods.

Full review comments:

  • [P2] Keep all probe cleanup within the five-second deadline — src/OpenClaw.SetupEngine/BoundedProcessOutput.cs:62
    The exit wait can consume the full five seconds, then Math.Max grants another 250 ms to drain and cleanup may wait another second. This contradicts the PR’s stated unchanged five-second bound; the maintained replacement already addresses it.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bd7702c5149a.

Labels

Label justifications:

  • P2: A stuck local Tailscale CLI delays setup guidance, but the defect has a contained repair path.
  • merge-risk: 🚨 availability: The changed timeout path controls whether the setup Capabilities page can remain responsive.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The supplied macOS terminal trace demonstrates an analogous process pattern, but it does not exercise the current-head Windows Capabilities-page owner or a Windows Tailscale invocation; the maintained replacement supplies Windows production-entry proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • andyeskridge: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • shanselman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Use the maintained replacement’s one-deadline implementation rather than merging this branch.
  • If this branch is retained, post redacted current-head Windows setup-path proof and update the PR body so ClawSweeper re-reviews automatically; otherwise ask a maintainer to comment @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-29T18:21:15.148Z sha d92edb7 :: needs real behavior proof before merge. :: [P2] Keep output draining inside the five-second deadline
  • reviewed 2026-09-02T17:23:33.583Z sha d92edb7 :: needs real behavior proof before merge. :: [P2] Keep the full probe within five seconds

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 2, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 2, 2026
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 2, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

Maintainer replacement: #1296. The original contributor branch could not accept the required current-main merge because the maintainer OAuth token lacks workflow scope. The replacement preserves this PR's commit, merges current origin/main without rebase or force, and adds the one-deadline repair, Windows hung-process proof, full validation, rubber-duck review, and clean autoreview at commit 19edb7d. No merge was performed.

@SebTardif

Copy link
Copy Markdown
Contributor Author

Superseded on current main.

#1296 landed BoundedProcessOutput (585c1776) for the Tailscale probe deadline. The file is on origin/main. Closing this older fork head instead of replaying it.

@SebTardif

Copy link
Copy Markdown
Contributor Author

Superseded by #1296 on main.

@SebTardif SebTardif closed this Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants