Repository navigation
[Repo Assist] fix: null _gatewayClient after dispose in OnSettingsSaved - #121
Merged
shanselman merged 1 commit intoApr 1, 2026
Conversation
When OnSettingsSaved switches to node mode, _gatewayClient was disposed but not set to null. This caused guards like if (_gatewayClient == null) return; in ShowQuickSend, RunHealthCheckAsync, and ToggleChannel to pass instead of short-circuiting, potentially calling into a disposed object (ObjectDisposedException) or producing unexpected behaviour. The _nodeService field already followed the correct pattern (null first, then dispose). Apply the same pattern to _gatewayClient. Co-authored-by: Copilot <[email protected]>
This was referenced Mar 31, 2026
shanselman
marked this pull request as ready for review
April 1, 2026 06:38
vincentkoc
deleted the
repo-assist/fix-settings-save-gateway-null-6bc718053d460466
branch
August 2, 2026 07:56
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 is an automated pull request from Repo Assist.
Summary
When
OnSettingsSavedswitches from operator mode to node mode,_gatewayClientwas disposed but not set to null. This left a dangling disposed reference that bypassed null guards in several callers:ShowQuickSend— logs a warning and returns if_gatewayClient == null, but when it's non-null and disposed the guard doesn't fireRunHealthCheckAsync— shows a "not connected" toast if_gatewayClient == null; without null, it calls into the disposed clientToggleChannel— early-returns on null; without null, calls into the disposed clientThe
_nodeServicefield already used the correct pattern (null first, then dispose). This PR applies the same one-line fix to_gatewayClient.Root cause
Fix rationale
The change is a single added line with no behaviour change on the gateway-mode path (where
InitializeGatewayClient()reassigns the field anyway). The fix only matters on the node-mode path whereInitializeNodeService()leaves_gatewayClientunreassigned.Trade-offs
None — this is a defensive correctness fix with no observable downside.
Test Status
dotnet test tests/OpenClaw.Shared.Tests/→ 503 passed, 18 skippeddotnet test tests/OpenClaw.Tray.Tests/→ 93 passedUnit tests for
App.xaml.csare not feasible (WinUI startup coupling), but the fix is a single-line change to a simple field assignment.