diff --git a/src/Core/Components/List/FluentCombobox.razor.cs b/src/Core/Components/List/FluentCombobox.razor.cs index 63bd266939..1cae063c18 100644 --- a/src/Core/Components/List/FluentCombobox.razor.cs +++ b/src/Core/Components/List/FluentCombobox.razor.cs @@ -177,11 +177,20 @@ protected override async Task ChangeHandlerAsync(ChangeEventArgs e) public new async ValueTask DisposeAsync() { - if (Module is not null && !string.IsNullOrEmpty(Id)) + try { - await Module.InvokeVoidAsync("detachIndicatorClickHandler", Id); - await Module.DisposeAsync(); + if (Module is not null && !string.IsNullOrEmpty(Id)) + { + await Module.InvokeVoidAsync("detachIndicatorClickHandler", Id); + await Module.DisposeAsync(); + } + await base.DisposeAsync(); + } + catch (Exception ex) when (ex is JSDisconnectedException || + ex is OperationCanceledException) + { + // The JSRuntime side may routinely be gone already if the reason we're disposing is that + // the client disconnected. This is not an error. } - await base.DisposeAsync(); } } diff --git a/src/Core/Components/Overlay/FluentOverlay.razor.cs b/src/Core/Components/Overlay/FluentOverlay.razor.cs index 8e15e405ed..d9fb4e68f9 100644 --- a/src/Core/Components/Overlay/FluentOverlay.razor.cs +++ b/src/Core/Components/Overlay/FluentOverlay.razor.cs @@ -266,11 +266,21 @@ private async Task OnCloseInternalHandlerAsync(MouseEventArgs e) /// public async ValueTask DisposeAsync() { - await InvokeOverlayDisposeAsync(); + try + { + await InvokeOverlayDisposeAsync(); + + if (_jsModule != null) + { + await _jsModule.DisposeAsync(); + } - if (_jsModule != null) + } + catch (Exception ex) when (ex is JSDisconnectedException || + ex is OperationCanceledException) { - await _jsModule.DisposeAsync(); + // The JSRuntime side may routinely be gone already if the reason we're disposing is that + // the client disconnected. This is not an error. } GlobalState.OnChange -= UpdateNeutralColor;