Repository navigation
Description
What
The tray's WSL gateway keep-alive can still run its ensure/start path during a Windows session-end sequence. The resulting wsl.exe creation fails with STATUS_DLL_INIT_FAILED (0xc0000142), which is what produces the shutdown "Application Error" dialog recorded as Application Popup, Event ID 26.
This issue covers one production file. It is the second of three spawn paths described in #1571. The first (the provenance probe's process start) is tracked separately; read #1571 for the evidence trail.
Where
src/OpenClaw.Tray.WinUI/App.xaml.cs
:956–:957— the keep-alive is started in a detached task:
var wslKeepAlive = new WslGatewayKeepAliveService(() => _settings, () => _gatewayRegistry);
_ = Task.Run(wslKeepAlive.TryEnsureAsync);:973— the managed-local auto-repair adapter invokes_ => wslKeepAlive.TryEnsureAsync()and discards the cancellation token it is handed.WslGatewayKeepAliveService.TryEnsureAsyncaccepts no cancellation token, and can launch WSL after asynchronous preparation — i.e. after the point where a caller could have decided not to.- The repair monitor that drives
:973issrc/OpenClaw.Tray.WinUI/Services/ManagedLocalGatewayAutoRepairMonitor.cs(5 s poll, 90 s cooldown); it keeps evaluating during teardown. ItsIsTransportUnreachablepath treats aConnectingstate with no classified error as unreachable, which is exactly the state observed after the WSL VM disappears at session end.
Scope — deliberately one file
- Change only
src/OpenClaw.Tray.WinUI/App.xaml.cs. - Do not change
ManagedLocalGatewayAutoRepairMonitor.cs,ManagedLocalGatewayRepairCoordinator.cs,WslGatewayKeepAliveService.csbeyond what this file's call sites require, or any document/config/schema. - Do not alter the 5 s poll interval, the 90 s cooldown, or the 3-restart budget.
- Do not add a new user-facing setting.
A previous single issue covering all three spawn paths produced an autonomous fix artifact that spanned three subsystems and was rejected upstream as too broad for autonomous execution. Keeping this to one file is the point of the split.
Required behaviour
- Once the process has observed that the Windows session is ending, the keep-alive path must not start a gateway — the detached task at
:957and the repair adapter at:973must both decline. - The repair adapter at
:973must honour the cancellation token it is given rather than discarding it with_ =>. - Normal operation is unchanged: at startup, and on every managed-local auto-repair while no session end is in progress, the keep-alive must still run.
- The session-ending signal must come from the same injected abstraction introduced for the provenance probe (separate issue), so there is one source of truth rather than a second ad-hoc check. If that abstraction is not available yet, define the call site against it rather than re-deriving the state locally.
- Refusal must be logged at the point of refusal so the tray log alone shows why nothing was started.
Acceptance
./build.ps1
dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
Required regression test
In tests/OpenClaw.Tray.Tests, a test that:
- substitutes a session-ending signal that reports "ending",
- drives the keep-alive entry point (and the repair adapter),
- asserts that no gateway start was attempted — and, separately, that the adapter's cancellation token is observed (a cancelled token must also prevent the start).
The test must not launch a real wsl.exe or need WSL installed.
What I can and cannot contribute
- I can confirm the reported behaviour on Windows 11 Home China build
10.0.26300with OpenClaw Companion2026.9.4.0, including tray-log lines showing the keep-alive/reconnect activity during teardown. - I do not have a working build environment for this repository, so I cannot run
./build.ps1or the test projects. Someone else needs to verify.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsBacklog
Activity
clawsweeper commentedon Oct 1, 2026
Codex review: this still needs some work.
Summary
Keep open: current main still discards repair cancellation and launches keep-alive processes without observing Windows session ending; the shared lifecycle prerequisite remains unresolved.
Reproducibility: Current source establishes token loss and unguarded process creation after asynchronous preparation; no builds, tests, or live shutdown reproduction ran in this read-only review.
Maintainer decision needed
Next step
Settle prerequisite sequencing, then forward cancellation and establish failing zero-launch regressions for session ending or cancellation before entry and during preparation.
Review details
Best possible solution:
Use the shared Windows lifecycle source and forwarded cancellation at keep-alive launch boundaries while preserving normal operation and logging refusals.
Do we have a high-confidence way to reproduce the issue?
Current source establishes token loss and unguarded process creation after asynchronous preparation; no builds, tests, or live shutdown reproduction ran in this read-only review.
Is this the best way to solve the issue?
The reporter's revised service-boundary scope is appropriate, but coverage must include WSL enumeration and cancellation during preparation rather than only App entry guards.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning medium; reviewed against 8ffe470e7d50.
Label changes
Label changes:
No label changes.
Label justifications:
P2: The cancellation defect and reported shutdown dialogs warrant repair without evidence of data loss or an unusable core workflow.impact:ux-friction: Shutdown-time application-error dialogs cause confusion and support burden, while the reporter confirms that the Gateway returns on the next boot.Evidence reviewed
Acceptance criteria:
What I checked:
src/OpenClaw.Tray.WinUI/App.xaml.cs:1129, 8ffe470e7d50)src/OpenClaw.Tray.WinUI/Services/WslGatewayKeepAliveService.cs:97, 8ffe470e7d50)src/OpenClaw.Connection/WslCommandRunner.cs:158, 8ffe470e7d50)src/OpenClaw.Tray.WinUI/Services/ManagedLocalGatewayRepairCoordinator.cs:383, 65de1e3584b3)tests/OpenClaw.Tray.Tests/ManagedLocalGatewayRepairCoordinatorTests.cs:702, 8ffe470e7d50)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 explainto ask for more context, or@clawsweeper stopto stop active automation.Reviewed November 19, 2026, 2:24 AM ET / 07:24 UTC.
petruslin commentedon Oct 1, 2026
Yes to widening this to the keep-alive cancellation boundary, now that #1575 exists
Filed as reporter: #1575 —
Provide one shared Windows session-ending signal and wire it for production use. It owns the shared signal, its Windows source, and the production wiring, and it deliberately does not touch the consumer call sites.On the question the review raises — whether this split repair may include minimal keep-alive service and regression-test changes — from the reporter's side: yes, and I think it has to.
The review's reasoning matches what I can observe from the outside:
WslGatewayKeepAliveService.TryEnsureAsyncaccepts no cancellation token, so once its asynchronous preparation is under way there is nothing at theApp.xaml.cslayer that can stop it from reaching the start path. An App-only guard therefore closes the two obvious entries (:957,:973) without delivering the guarantee this issue claims.The narrowest form that does deliver it:
src/OpenClaw.Tray.WinUI/App.xaml.cs— no start while a session end is in progress; the repair adapter at:973must respect the cancellation token it is already handed.src/OpenClaw.Tray.WinUI/Services/WslGatewayKeepAliveService.cs— a minimal cancellation boundary insideTryEnsureAsync, so it can observe the signal before it starts anything.TryEnsureAsyncdoes not reach a process start; with no session end, it behaves exactly as today.Explicitly not in scope, as before: the 5 s poll interval, the 90 s cooldown, and the 3-restart budget. I am not asking to change keep-alive behaviour in normal operation — only to give it a way to stop when Windows is ending.
If the maintainer prefers to keep this issue at one file and track the service change separately, that is fine too; the two are separable as long as both land. I would just rather say plainly that the one-file version does not fully close the reported defect.
github-actions commentedon Oct 16, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updated OpenClaw Windows details or it will be closed.
github-actions commentedon Nov 18, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updated OpenClaw Windows details or it will be closed.