Skip to content

P0: async void event handlers are a process-crash hazard across the WinUI codebase #552

@QQSHI13

Description

@QQSHI13

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.csOnLaunched, ShowTrayMenuPopup, ToggleChannel, OnSshTunnelExited
  • src/OpenClaw.Tray.WinUI/Pages/*Page.xaml.csConnectionPage, VoiceSettingsPage, PermissionsPage, ConfigPage, etc.
  • src/OpenClaw.Tray.WinUI/Windows/*Window.xaml.csCanvasWindow.InitializeWebViewAsync, SetupWizardWindow, VoiceOverlayWindow
  • src/OpenClaw.Connection/GatewayConnectionManager.csOnNodeStatusChanged, OnNodePairingStatusChanged
  • src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.csAckAction, 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

  1. Add a centralized FireAndForget(Func<Task> work, Action<Exception>? onError = null) helper.
  2. Refactor handlers to call the real work via InnerFooAsync().FireAndForget(_logger).
  3. For XAML event handlers that must keep the async void signature, enforce a one-line body that delegates to the guarded helper.

Files

  • src/OpenClaw.Tray.WinUI/App.xaml.cs
  • src/OpenClaw.Tray.WinUI/Pages/*.xaml.cs
  • src/OpenClaw.Tray.WinUI/Windows/*.xaml.cs
  • src/OpenClaw.Connection/GatewayConnectionManager.cs
  • src/OpenClaw.Tray.WinUI/Chat/OpenClawChatTimeline.cs

Metadata

Metadata

Assignees

No one assigned

    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

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions