Repository navigation
Description
Problem
CommandRunner waits for redirected stdout and stderr EOF after the direct child exits, but gives every command only 250 ms for the asynchronous output callbacks to finish draining.
openclaw-windows-node/src/OpenClaw.SetupEngine/CommandRunner.cs
Lines 193 to 199 in 31dffdb
| } | |
| // A surviving descendant can keep inherited pipe handles open after the child | |
| // exits. Preserve output already in flight without charging the command's full | |
| // timeout to an EOF that may never arrive. | |
| await Task.WhenAny( | |
| Task.WhenAll(stdoutClosed.Task, stderrClosed.Task), |
The bounded drain was introduced to prevent setup from hanging when a surviving descendant inherits the redirected pipe handles. The immediate motivating command was the Welcome-page WSL inspection:
wsl.exe --list --quiet
| var logger = new SetupLogger(filePath: null, LogLevel.Warn); | |
| var result = new CommandRunner(logger) | |
| .RunAsync(WslConstants.WslExePath, ["--list", "--quiet"], TimeSpan.FromSeconds(5)) | |
| .GetAwaiter() | |
| .GetResult(); | |
| var hasDistro = InterpretDistroList(result, targetDistroName); |
That inherited-handle scenario is legitimate, but the 250 ms escape now applies to all CommandRunner and RunInWslAsync calls, including commands whose complete output is parsed as JSON or checked for trailing success markers. Examples include:
wsl.exe -d <distro> -- bash -c "<path-prefix> && openclaw nodes list --json"
wsl.exe -d <distro> -- bash -c "<path-prefix> && openclaw devices approve --latest --json"
wsl.exe -d <distro> -- bash -c "<path-prefix> && openclaw qr --json"
The setup flow also checks trailing markers such as GATEWAY_CONFIGURED, CONFIGURED_OK, OPENCLAW_FRESH_WSL_READY, and WINDOWS_NODE_CONTEXT_READY.
Impact
If output callbacks are still draining when the 250 ms delay wins, setup can receive truncated JSON or miss a final success marker despite a successful child exit. This can produce parse failures or false setup failures.
Expected behavior
- Preserve complete stdout and stderr when the direct child closed its pipe handles normally.
- Keep a bounded escape for the case where surviving descendants retain inherited handles.
- Preserve existing process timeout and caller-cancellation behavior.
- Do not regress the no-hang behavior for orphan or background WSL descendants.
Tests
- Add a high-volume command whose required JSON or marker is emitted at the end and assert that it is captured.
- Retain the existing descendant-keeps-pipes-open test.
- Cover stdout and stderr draining.
- Cover timeout and caller cancellation.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Aug 21, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed September 7, 2026, 9:12 PM ET / September 8, 2026, 01:12 UTC.
Summary
Current main still allows successful commands to return before stdout and stderr finish draining. The cap is now three seconds rather than 250 ms, but the reported mechanism remains. The open repair at #1361 explicitly owns this work.
Likely related people: shanselman and Dallin Romney are low-confidence routing candidates based on the repair discussion and recent area history.
Reproducibility: yes. source establishes a clear trigger: pending output callbacks when the normal drain budget expires cause an early result snapshot. A failing runtime reproduction was not executed in this read-only review.
Next step
Review and resolve #1361 before closing this issue; its explicit ownership rules out dispatching another repair.
Review details
Best possible solution:
Normal exits should drain both streams to EOF within existing capture-size limits, honor caller cancellation, and reserve bounded escape for explicit inherited-pipe inspections and timeout cleanup.
Do we have a high-confidence way to reproduce the issue?
Yes, source establishes a clear trigger: pending output callbacks when the normal drain budget expires cause an early result snapshot. A failing runtime reproduction was not executed in this read-only review.
Is this the best way to solve the issue?
Yes, the linked repair's separation of normal EOF draining from explicit inherited-pipe escape addresses the mechanism more directly than increasing a universal delay.
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning medium; reviewed against 6d1056270082.
Label changes
Label justifications:
P1: Premature output snapshots can turn successful provisioning and pairing commands into setup failures, consistent with the recorded human priority escalation.impact:other: The affected behavior is setup command-result integrity, causing incomplete JSON or missing completion markers.Evidence reviewed
What I checked:
src/OpenClaw.SetupEngine/CommandRunner.cs:222, 6d1056270082)src/OpenClaw.SetupEngine/MintBootstrapTokenStep.cs:32, 6d1056270082)tests/OpenClaw.SetupEngine.Tests/CommandRunnerTests.cs:138, 6d1056270082)src/OpenClaw.SetupEngine/CommandRunner.cs, cb610b2b3d4e)Likely related people:
How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.7 remaining items