Repository navigation
Closed
Labels
P1Urgent regression or broken agent/channel workflow affecting real users now.bugSomething isn't workingclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopThis issue is about crashes, hangs, restart loops, or process-level availability.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
Description
Problem
There are ~30+ async void methods in the WinUI layer (code-behind event handlers, node status callbacks, etc.). An unhandled exception in any of them bypasses WinUI's UnhandledException handler and terminates the process.
Notable locations:
src/OpenClaw.Tray.WinUI/App.xaml.cs—OnLaunched,ShowTrayMenuPopup,ToggleChannel,OnSshTunnelExitedsrc/OpenClaw.Tray.WinUI/Pages/*Page.xaml.cs—ConnectionPage,VoiceSettingsPage,PermissionsPage,ConfigPage, etc.src/OpenClaw.Tray.WinUI/Windows/*Window.xaml.cs—CanvasWindow.InitializeWebViewAsync,SetupWizardWindow,VoiceOverlayWindowsrc/OpenClaw.Connection/GatewayConnectionManager.cs—OnNodeStatusChanged,OnNodePairingStatusChangedsrc/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs—AckAction,ReadAloud
PermissionsPage.EnsureWhisperModelDownloadedAsync already contains a giant try/catch with an explicit comment explaining this exact risk — which proves the team has been bitten by it before.
Impact
- Editing any screen risks introducing a new crash path.
- There is no centralized guard; each author must remember to wrap every statement.
- Production crashes are hard to diagnose because the stack trace originates from the dispatcher, not user code.
Suggested fix
- Add a centralized
FireAndForget(Func<Task> work, Action<Exception>? onError = null)helper. - Refactor handlers to call the real work via
InnerFooAsync().FireAndForget(_logger). - For XAML event handlers that must keep the
async voidsignature, enforce a one-line body that delegates to the guarded helper.
Files
src/OpenClaw.Tray.WinUI/App.xaml.cssrc/OpenClaw.Tray.WinUI/Pages/*.xaml.cssrc/OpenClaw.Tray.WinUI/Windows/*.xaml.cssrc/OpenClaw.Connection/GatewayConnectionManager.cssrc/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs
Reacted by clawsweeper
Metadata
Metadata
Assignees
Labels
P1Urgent regression or broken agent/channel workflow affecting real users now.bugSomething isn't workingclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopThis issue is about crashes, hangs, restart loops, or process-level availability.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Activity
clawsweeper commentedon May 27, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 27, 2026, 9:55 AM ET / 13:55 UTC.
Summary
This issue is still necessary: current main still contains the reported unguarded
async voidconnection handlers and a broad remaining WinUI surface, while the linked automation PR only covers two connection-layer handlers.Reproducibility: yes. from source inspection: current main awaits inside
async voidconnection handlers before any catch block, and several WinUI/chat handlers remain unguarded. I did not run a live Windows crash reproduction because this is a read-only review.Next step
Maintainers should first decide sequencing with the open partial connection-layer PR, then promote a broader WinUI guard pass if that PR does not expand scope.
Review details
Best possible solution:
Keep this issue open as the umbrella, review or land the connection-layer guard from the linked draft PR or equivalent, then add a shared guarded fire-and-forget helper and refactor the remaining WinUI/page/window/chat handlers with focused regression coverage and Windows smoke validation.
Do we have a high-confidence way to reproduce the issue?
Yes from source inspection: current main awaits inside
async voidconnection handlers before any catch block, and several WinUI/chat handlers remain unguarded. I did not run a live Windows crash reproduction because this is a read-only review.Is this the best way to solve the issue?
Yes in direction: a centralized guarded fire-and-forget helper with one-line event-handler delegation is the narrow maintainable fix. The best sequencing is to handle the open connection-layer partial PR first, then do the broader WinUI pass.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against bf21e7b216aa.
Label changes
Label changes:
P1: Current main has source-confirmed process-crash paths in async-void connection/UI handlers, but no confirmed active crash loop or unusable runtime state.impact:crash-loop: The issue is about unhandled exceptions escaping event handlers and terminating the tray process.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:fix-shape-clear: Current issue advisory state selects this label.clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.Label justifications:
P1: Current main has source-confirmed process-crash paths in async-void connection/UI handlers, but no confirmed active crash loop or unusable runtime state.impact:crash-loop: The issue is about unhandled exceptions escaping event handlers and terminating the tray process.Evidence reviewed
Acceptance criteria:
What I checked:
AGENTS.md:1, bf21e7b216aa)OnNodeStatusChangedandOnNodePairingStatusChangedareasync void; both await_transitionSemaphore.WaitAsync()before any catch block, so an exception there would escape the handler. (src/OpenClaw.Connection/GatewayConnectionManager.cs:770, bf21e7b216aa)Dispose()already comments that node event unsubscription is needed before disposing the semaphore to prevent async-void handlers from crashing viaObjectDisposedException. (src/OpenClaw.Connection/GatewayConnectionManager.cs:959, bf21e7b216aa)rgfound async-void handlers across the connection layer, tray pages, windows, chat timeline, app startup/tray code, and SetupEngine UI. (bf21e7b216aa)OpenClawChatRoothas a privateRunFireAndForgethelper, but it is local to that component and does not protect the reported page/window/app handlers. (src/OpenClaw.Tray.WinUI/Chat/OpenClawChatRoot.cs:884, bf21e7b216aa)EnsureWhisperModelDownloadedAsyncexplicitly says uncaught async-void exceptions bypass WinUI handling and wraps the full body in a last-resort catch. (src/OpenClaw.Tray.WinUI/Pages/PermissionsPage.xaml.cs:228, bf21e7b216aa)Likely related people:
Fix tray disconnected behavior. (role: introduced current affected implementation; confidence: high; commits: 6d8541e57008, 7747e6075052, cefce3952ab1; files:src/OpenClaw.Connection/GatewayConnectionManager.cs,src/OpenClaw.Tray.WinUI/App.xaml.cs,src/OpenClaw.Tray.WinUI/Pages/PermissionsPage.xaml.cs)src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs,src/OpenClaw.Tray.WinUI/Chat/OpenClawChatRoot.cs,src/OpenClaw.Tray.WinUI/App.xaml.cs)OpenClawChatTimeline, which still contains async-void local handlers. (role: recent chat timeline contributor; confidence: medium; commits: bf21e7b216aa, 0a164fc111b2; files:src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs)src/OpenClaw.Connection/GatewayConnectionManager.cs,src/OpenClaw.Tray.WinUI/App.xaml.cs)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.github-actions commentedon May 27, 2026
🤖 This is an automated response from Repo Assist.
The issue is well-scoped. I looked at the two highest-risk locations:
GatewayConnectionManager.OnNodeStatusChangedandOnNodePairingStatusChanged— both areasync voidand both have anawait _transitionSemaphore.WaitAsync()before anycatchblock. If that semaphore or anything before thetrythrows, the exception is entirely uncontained and will terminate the process via the thread pool's unhandled exception path (not WinUI'sUnhandledException, which only covers UI thread exceptions).I've opened a PR that adds a top-level
try/catch(Exception ex)around the full body of both handlers, logging via_logger.Warnand_diagnostics.Record. This is the narrowest safe fix for the connection layer and can be validated with the existing test suite.For the broader WinUI surface (App.xaml.cs, Page code-behind, etc.), the
RunFireAndForgetpattern already inOpenClawChatRootis the right model. Those handlers will need a separate pass — the change is safe but spans many files and needs Windows UI testing.fix(connection): guard async void event handlers against unhandled ex…
shanselman commentedon May 28, 2026
Addressed by merged PR #564. The source async-void handler surface was converted to guarded Task delegation, with a regression test preventing new source async-void handlers.