[Repo Assist] fix(dispatch): remove empty catch swallows; add SafeDispatch/SafeEventInvoke helpers#406
Draft
github-actions[bot] wants to merge 2 commits into
Conversation
…ispatch helpers Closes #365 - Add SafeDispatch.cs with SafeEnqueue and SafeInvoke<T> extension helpers - Remove 15 useless try { DispatcherQueue?.TryEnqueue(...) } catch { } blocks in HubWindow.xaml.cs — TryEnqueue returns bool, never throws - Replace 11 silent try { event?.Invoke(...) } catch { } patterns in AudioPipeline.cs with SafeInvoke, which logs a Warn when a handler throws instead of swallowing the exception silently Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover SafeEventInvoke<T> and SafeInvoke (no-arg) helpers: - null handler is a no-op - single handler is called with correct argument - multiple handlers all fire in order - throwing handler does not propagate exception to caller - throwing handler logs a Warn via IOpenClawLogger - remaining handlers still fire after a throwing one Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #365
Root Cause
Audit of
src/found two recurring AI-slop patterns:try { DispatcherQueue?.TryEnqueue(...) } catch { }—TryEnqueuereturnsbooland never throws. The try/catch was doing literally nothing, silently hiding any future exception placed inside the lambda.try { event?.Invoke(...) } catch { }— Silently swallows exceptions thrown by event handlers. Symptoms appear as "activity stream randomly stops updating" with no log entry.Fix
New helpers (
Helpers/SafeDispatch.cs,Helpers/SafeEventInvoke.cs)HubWindow.xaml.cstry { DispatcherQueue?.TryEnqueue(...) } catch { }blocks. The dispatcher call is now direct; the two intentional catches (settings save with comment, and the typedcatch (Exception ex)) are untouched.AudioPipeline.cstry { DiagnosticMessage?.Invoke(...) } catch { }/try { VoiceActivityChanged?.Invoke(...) } catch { }patterns withSafeInvoke(..., _logger). Exceptions from handlers are now logged at Warn rather than discarded.Trade-offs
SafeEnqueueis thin — it exists as a named intent marker and to make future callers consistent.Test Status
Linux CI (this run)
dotnet test OpenClaw.Shared.Tests→ 1565 passed, 7 pre-existing failures, 28 skipped ✅dotnet test OpenClaw.Tray.Tests→ 1165 passed (+9 new), 7 pre-existing failures, 47 skipped ✅build.ps1requires Windows (MakePri.exe); build is infrastructure-limited on Linux — not caused by these changes.New tests
9 unit tests in
SafeEventInvokeTests.cscovering null-safety, single/multi handler invocation, exception containment, and logger integration.Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
az667904.vo.msecnd.netvortex.data.microsoft.comSee Network Configuration for more information.