fix(centralui): safe-invoke fire-and-forget calls in AlarmSummary and TreeView (review 2026-10-21 07/M-4)
This commit is contained in:
@@ -207,7 +207,7 @@ else
|
||||
// Clear selection if the selected key no longer exists in the current items tree
|
||||
if (Selectable && SelectedKey != null && _items is not null && !KeyExistsInTree(_items, SelectedKey))
|
||||
{
|
||||
_ = SelectedKeyChanged.InvokeAsync(null);
|
||||
_ = SafeFireAndForgetAsync(() => SelectedKeyChanged.InvokeAsync(null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,10 +553,22 @@ else
|
||||
if (StorageKey != null)
|
||||
{
|
||||
var json = System.Text.Json.JsonSerializer.Serialize(_expandedKeys.ToList());
|
||||
_ = JSRuntime.InvokeVoidAsync("treeviewStorage.save", StorageKey, json);
|
||||
_ = SafeFireAndForgetAsync(() =>
|
||||
JSRuntime.InvokeVoidAsync("treeviewStorage.save", StorageKey, json).AsTask());
|
||||
}
|
||||
}
|
||||
|
||||
// Fire-and-forget calls (an EventCallback, a JS persist) can race circuit teardown;
|
||||
// swallow the expected disposal/disconnect failures so no unobserved-task exception
|
||||
// reaches the log (review 2026-10-21 07/M-4).
|
||||
private static async Task SafeFireAndForgetAsync(Func<Task> work)
|
||||
{
|
||||
try { await work(); }
|
||||
catch (ObjectDisposedException) { }
|
||||
catch (JSDisconnectedException) { }
|
||||
catch (TaskCanceledException) { }
|
||||
}
|
||||
|
||||
private async Task OnContentClick(object key)
|
||||
{
|
||||
// Clicking a node makes it the tab entry point (roving tabindex follows the
|
||||
|
||||
Reference in New Issue
Block a user