Repository navigation
Description
What
The WebSocket reconnect retry loop keeps running during a Windows session-end sequence. Its next step is ReconnectAuthorizationAsync, which routes through endpoint provenance and can reach the managed-local port probe — the code path that starts wsl.exe. Creating that process at teardown fails with STATUS_DLL_INIT_FAILED (0xc0000142) and produces the shutdown "Application Error" dialog recorded as Application Popup, Event ID 26.
This issue covers one production file. It is the third of three spawn paths described in #1571; read #1571 for the evidence trail (the 16-day Event 26 burst census, the tray log excerpts, and why the unrelated XLGuard.sys boot popup must be counted separately).
Where
src/OpenClaw.Shared/WebSocketClientBase.cs
- The reconnect retry loop sits around
:594. It checks disposal, its cancellation token, the reconnect policy and the socket generation, then continues into authorization. ReconnectAuthorizationAsyncis declared at:156–:157and invoked at:618–:621:
await ReconnectAuthorizationAsync(_cts.Token).ConfigureAwait(false);_ctsis the client's own token source (:102, created at:228); it is cancelled by the client's teardown, but that teardown is order-dependent and does not observe a Windows session-end sequence.- Neither this loop nor the authorization path consults a session-ending signal.
Scope — deliberately one file
- Change only
src/OpenClaw.Shared/WebSocketClientBase.cs. - Do not change
src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs(separate issue),src/OpenClaw.Tray.WinUI/App.xaml.cs(separate issue), or any document/config/schema. - Do not change reconnect backoff, the reconnect policy, or the disposal ordering.
- 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 reconnect loop must exit before invoking
ReconnectAuthorizationAsync— the call at:621must not be reached. - Normal reconnects are unchanged: with no session end in progress, the loop must behave exactly as today, including its existing token/policy/generation checks.
- The check must not depend on the client's own
_ctsbeing cancelled at the right moment; that race is the current gap. - The session-ending signal must come from the same injected abstraction used by the other two call sites, so there is one source of truth. If that abstraction is not yet available, code the call site against it rather than re-deriving the state locally.
- Declining must be logged at the point of refusal.
WebSocketClientBaselives in a shared library with no window; do not add a Win32/tray dependency to it. Take the signal as an abstraction.
Acceptance
./build.ps1
dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
Required regression test
In tests/OpenClaw.Shared.Tests, a test that:
- substitutes a session-ending signal that reports "ending",
- drives the reconnect path,
- asserts that
ReconnectAuthorizationAsyncis not invoked, - and that with the signal reporting "not ending" it is invoked.
Assert on a substituted ReconnectAuthorizationAsync delegate (it is already settable at :156), not on a real socket or a real wsl.exe.
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 showingConnection closed prematurelyfollowed byreconnecting in …during teardown, and the matching Event 1074 → Event 26 ordering. - 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 this issue open: current main still reaches reconnect authorization without observing Windows session end, and the shared lifecycle prerequisite remains unresolved.
Reproducibility: Current source proves authorization remains reachable after backoff without observing Windows session end; the delegate seam supports a deterministic regression, but no tests or live shutdown reproduction ran in this read-only review.
Root-cause cluster
Relationship:
partial_overlapCanonical: #1571
Summary: The reporter preserves one evidence umbrella with separate repairs for the shared lifecycle producer and individual launch-admission boundaries.
Members:
canonical: Tray spawnswsl.exeduring session teardown, producing an "Application Error 0xc0000142" popup on every shutdown/restart #1571 - Owns the shared shutdown evidence and explicitly retains the split consumer issues.partial_overlap: Provide one shared Windows session-ending signal and wire it for production use #1575 - Owns the prerequisite lifecycle source and production registration, excluding this consumer.partial_overlap: Gate the managed-local provenance probe so it cannot start wsl.exe during Windows session teardown #1572 - Protects the downstream provenance process-start boundary independently.partial_overlap: Tray keep-alive can still start during Windows session end and its repair adapter ignores the cancellation token #1573 - Protects keepalive admission and cancellation propagation.adjacent_distinct: [Bug] Hub 2026.9.8-1: premature WebSocket closures and lost system.run.prepare result with WSL Gateway #1689 - Explicitly reports transport failures without Windows shutdown and does not establish this cause.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
Establish the wired lifecycle contract in #1575, then guard authorization with failing regressions for session end before retry, during backoff, and normal operation.
Review details
Best possible solution:
Use one host-owned lifecycle signal to stop and log reconnect admission during session end while preserving normal retries and endpoint authorization.
Do we have a high-confidence way to reproduce the issue?
Current source proves authorization remains reachable after backoff without observing Windows session end; the delegate seam supports a deterministic regression, but no tests or live shutdown reproduction ran in this read-only review.
Is this the best way to solve the issue?
An injected admission guard fits the defect, but the requested one-file repair depends on the shared lifecycle producer and real production wiring rather than an independent flag or no-op default.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning medium; reviewed against e9423aed4ba9.
Label changes
Label changes:
No label changes.
Label justifications:
P2: Shutdown-time background process failures warrant repair without evidence of data loss or a blocked first-use workflow.impact:ux-friction: Reconnect work during shutdown can produce alarming Windows application-error dialogs.Evidence reviewed
Acceptance criteria:
What I checked:
src/OpenClaw.Shared/WebSocketClientBase.cs:772, e9423aed4ba9)src/OpenClaw.Connection/GatewayConnectionManager.cs:729, e9423aed4ba9)src/OpenClaw.Connection/ManagedLocalGatewayPortProvenanceService.cs:100, e9423aed4ba9)tests/OpenClaw.Shared.Tests/WebSocketClientBaseTests.cs:227, e9423aed4ba9)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, 10:56 PM ET / November 20, 2026, 03:56 UTC.
petruslin commentedon Oct 1, 2026
The prerequisite now exists: #1575
Filed as reporter: #1575 —
Provide one shared Windows session-ending signal and wire it for production use. It owns the abstraction, the concrete Windows source and its production registration, and it does not touch this call site or the other two.That resolves the gap the review identified here — that all three split issues depend on one signal which the source does not currently provide, and that independently-defined seams could end up incompatible or unwired. Nothing about this issue's own scope changes: still one production file,
src/OpenClaw.Shared/WebSocketClientBase.cs, and still no Win32 or tray dependency in that shared library.Two things the review asked for, which I agree to:
It has to expose the transition, not just a latched state. The interesting case is a session end that begins while the reconnect loop is already sitting in its backoff wait. A flag that only becomes readable once teardown is under way can be sampled too early and miss it. #1575 asks for the transition for exactly this reason; if the implementation only offers a latched state, this issue will not be able to honour its own requirement 1 reliably.
The regression cases. Happy to have these as the acceptance evidence:
ReconnectAuthorizationAsyncis not invoked.All three should be driven through the settable delegate at
:156, with no real socket and no realwsl.exe.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 19, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updated OpenClaw Windows details or it will be closed.