Repository navigation
fix(daemon): keep hidden Windows launcher alive for the daemon's lifetime - #123774
bmorenmiami-droid wants to merge 1 commit into
Conversation
…time The .vbs launcher generated for OPENCLAW_WINDOWS_TASK_HIDDEN_LAUNCHER=1 used bWaitOnReturn=False, which made WScript exit immediately after launching cmd.exe. schtask then recorded "Last Result: 0" and treated the task as complete, leaving the gateway process as an untracked orphan holding the bind port. The next `openclaw gateway start` would wedge with: Gateway failed to start: gateway already running (pid <orphan>); lock timeout after 5000ms Switching bWaitOnReturn to True keeps the WScript host alive for the entire lifetime of the cmd.exe + node.exe tree, so schtask tracks the daemon and restart logic can see the real state. Verified locally by inspecting generated .vbs content and adding a regression test that asserts both the True flag and the absence of False.
|
🦞👀 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 real behavior proof before merge. Reviewed September 29, 2026, 11:18 PM ET / September 30, 2026, 03:18 UTC. ClawSweeper reviewWhat this changesThe branch makes the optional hidden Windows Scheduled Task launcher wait for the Gateway command and updates launcher and UTF-16 encoding tests. Merge readiness⛔ Blocked before merge - 6 items remain Current main and v2026.9.1 already contain the waiting-launcher repair, but the merged replacement has no verified formal GitHub closing link to this PR. Its supersession therefore needs explicit maintainer disposition before closure. Priority: P2 Review scores
Verification
How this fits togetherWindows Gateway installation writes a command script and, when hidden launching is enabled, a WScript wrapper for Task Scheduler. Task Scheduler observes the wrapper while the command starts and runs the Gateway. flowchart LR
A[Hidden launcher setting] --> B[Gateway task installer]
B --> C[Command script]
B --> D[WScript launcher]
D --> E[Task Scheduler]
E --> F[Running Gateway]
F --> G[Task status and exit result]
Decision needed
Why: The exact behavior is shipped, but the review contract does not permit an automatic PR close without a verified formal connection to the request. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +6, Tests +27. Total +33 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the released supervisor and its exit propagation; if any branch work is reused, fold its useful explanation into a short comment at the current launcher owner. Do we have a high-confidence way to reproduce the issue? No current-main failure was reproduced: its installer emits a waiting launcher, while the pinned pre-fix source shows the historical non-waiting path. Is this the best way to solve the issue? No. The merged supervisor is the better owner-boundary fix because it waits and propagates the command result; this branch waits but discards that result. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b2cda568987e; fix evidence: release v2026.9.1, commit 14e26a380d34. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Ayushdevo
left a comment
There was a problem hiding this comment.
The bWaitOnReturn change is internally consistent across the launcher generation and UTF-16 regression coverage, but there is one cleanup item before merge: the production source comment contains the literal placeholder URL https://github.com/openclaw/openclaw/issues/<this-fix>. That will land verbatim. Please replace it with the actual issue/PR reference or remove the URL.
|
Thanks for the launcher repair. The same waiting behavior is already merged in #132186 with explicit exit-code propagation, and #141744 covers descendant shutdown and fresh starts. Current main retains both repairs and their regression coverage, so this PR can close as superseded. If a refreshed installation still shows a distinct orphan or restart failure, please share the reproduction so we can reopen that gap. |
PR body
Resolves the orphan-on-restart wedge where the .vbs launcher generated for
OPENCLAW_WINDOWS_TASK_HIDDEN_LAUNCHER=1exits with code 0 immediately after launching cmd.exe. schtask then recordsLast Result: 0and loses its handle to the actual gateway process tree, so the nextopenclaw gateway startwedges with "gateway already running (pid ); lock timeout after 5000ms."What changes
buildHiddenLauncherScript()insrc/daemon/schtasks-layout.tsnow emits:instead of
, 0, False.bWaitOnReturn=Truekeeps the WScript host alive for the entire lifetime of the cmd.exe + node.exe process tree, so schtask correctly tracks the daemon and restart logic sees the real state.A regression test asserts both
Trueis present andFalseis absent in the generated .vbs.Files
src/daemon/schtasks-layout.ts— 1-line behavioral change + explanatory commentsrc/daemon/schtasks.install.test.ts— 3 existing assertions + 1 new regression testsrc/infra/windows-launcher-encoding.test.ts— 3 fixture-string updates (UTF-16 LE round-trip)Test plan
src/daemon/schtasks.install.test.tsandsrc/infra/windows-launcher-encoding.test.tssuites continue to pass (assertions flipped fromFalsetoTrue)."emits a hidden launcher that waits for the cmd tree so the daemon is not orphaned on restart"— installs a default gateway task withOPENCLAW_WINDOWS_TASK_HIDDEN_LAUNCHER=1, reads the generated .vbs, and asserts on thebWaitOnReturnflag.Out of scope (follow-ups)
schtasks /Endstill only kills the top-level WScript; the cmd.exe and node.exe children survive. Wrapping node.exe in a Win32 Job Object (JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE) and invoking the daemon via a small PowerShell launcher would close that gap. Happy to send a follow-up PR.openclaw gateway startorphan detection. The CLI's lock-file check still only verifies "is the PID alive," not "is the PID's parent still tracked by schtask." A second follow-up could teach the CLI to detect and reap true orphans.Risk
0artifact).gateway.cmdonly, no .vbs).Reproduction / verification
Before the fix, on the host running openclaw 2026.6.34:
i.e., the task "ran" (and finished cleanly) two minutes before the failed restart attempt at 10:47:44.
After the fix,
Last Run TimeandStatus: Runningtrack the actual daemon lifetime, andLast Resultreflects the daemon's exit code on shutdown.