Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor - using SingalR hub to force refresh all user tabs logs multiple TaskCanceledException (RefreshFailed and CircuitUnhandledException)

$
0
0

I am using SignalR hub to refresh all tabs currently opened by specified user (e.g. after permission change). Hub connection is initialized in the MainLayout component.

    private async Task InitHub()    {        _hubConnection = new HubConnectionBuilder()            .WithUrl(_navigationManager.ToAbsoluteUri($"{HubConstants.Connection.Route}"), opts =>            {                opts.UseDefaultCredentials = true;            })            .Build();        _hubConnection.On($"{HubConstants.Connection.ForcePageRefresh}",() =>        {            _navigationManager.Refresh();        });        await _hubConnection.StartAsync();    }

MainLayout component implements IAsyncDisposable

    public async ValueTask DisposeAsync()    {        if (_hubConnection != null)            await _hubConnection.DisposeAsync();        GC.SuppressFinalize(this);    }

When I have 3 tabs opened I am receiving message to take action in more than 3 hub connections (4,5 ... 8 etc. - it depends on how many navigations I did in all tabs/sessions before sending message to the hub).

My app is not crashing anyway, tabs are refreshing correctly but I am getting multiple errors in my logs/output. Do you have any suggestions how to manage these errors, avoid them or just ignore?

Also I need only one hub connection for a tab/session. How to achieve that?

2024-08-21T08:31:21.4910599+02:00 FAIL [Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager] [RefreshFailed] Failedto refreshSystem.Threading.Tasks.TaskCanceledException: A task wascanceled. atMicrosoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64targetInstanceId, String identifier, Object[] args) atMicrosoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntimejsRuntime, String identifier, Object[] args) atMicrosoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass14_0.<g__RefreshAsync|0>d.MoveNext()

2024-08-21T08:31:21.4913339+02:00 FAIL [Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager] [RefreshFailed] Failedto refreshSystem.Threading.Tasks.TaskCanceledException: A task wascanceled. atMicrosoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64targetInstanceId, String identifier, Object[] args) atMicrosoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntimejsRuntime, String identifier, Object[] args) atMicrosoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass14_0.<g__RefreshAsync|0>d.MoveNext()

2024-08-21T08:31:21.4916513+02:00 FAIL [Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager] [RefreshFailed] Failedto refreshSystem.Threading.Tasks.TaskCanceledException: A task wascanceled. atMicrosoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64targetInstanceId, String identifier, Object[] args) atMicrosoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntimejsRuntime, String identifier, Object[] args) atMicrosoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass14_0.<g__RefreshAsync|0>d.MoveNext()

2024-08-21T08:31:21.4917755+02:00 FAIL [Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost] [CircuitUnhandledException] Unhandledexception in circuit'Jy_Vk4kXbB_5BNnlB3vjcE_IjYyd9hwBHrTJjSZ-GYY'.System.Threading.Tasks.TaskCanceledException:A task was canceled. atMicrosoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64targetInstanceId, String identifier, Object[] args) atMicrosoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntimejsRuntime, String identifier, Object[] args) atMicrosoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass14_0.<g__RefreshAsync|0>d.MoveNext()

2024-08-21T08:31:21.4919112+02:00 FAIL [Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost] [CircuitUnhandledException] Unhandledexception in circuit'1Tkms7B8ImnvfBz46J8g8eC1mSRYYhBqpg7ekkqVW6M'.System.Threading.Tasks.TaskCanceledException:A task was canceled. atMicrosoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64targetInstanceId, String identifier, Object[] args) atMicrosoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntimejsRuntime, String identifier, Object[] args) atMicrosoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass14_0.<g__RefreshAsync|0>d.MoveNext()

2024-08-21T08:31:21.4932280+02:00 FAIL [Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager] [RefreshFailed] Failedto refreshSystem.Threading.Tasks.TaskCanceledException: A task wascanceled. atMicrosoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64targetInstanceId, String identifier, Object[] args) atMicrosoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntimejsRuntime, String identifier, Object[] args) atMicrosoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass14_0.<g__RefreshAsync|0>d.MoveNext()

2024-08-21T08:31:21.4937636+02:00 FAIL [Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost] [CircuitUnhandledException] Unhandledexception in circuit'T5PzUx1qUgkhZLT-u-BQqEBfuYX8aDfUWPvh-og7ZHk'.System.Threading.Tasks.TaskCanceledException:A task was canceled. atMicrosoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64targetInstanceId, String identifier, Object[] args) atMicrosoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntimejsRuntime, String identifier, Object[] args) atMicrosoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass14_0.<g__RefreshAsync|0>d.MoveNext()

2024-08-21T08:31:21.4949202+02:00 FAIL [Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost] [CircuitUnhandledException] Unhandledexception in circuit'spD_gRuMVnJ1O6F0Q_qk9osI-Orce3cP0_4Ucksbt5U'.System.Threading.Tasks.TaskCanceledException:A task was canceled. atMicrosoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64targetInstanceId, String identifier, Object[] args) atMicrosoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntimejsRuntime, String identifier, Object[] args) atMicrosoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass14_0.<g__RefreshAsync|0>d.MoveNext()


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>