question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(BlazorServer) each navigation to external logs 2 errors a minute later

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Each time you leave the blazor circuit a minute later two exceptions are logged.

Expected Behavior

zero errors in log when no one does wrong things.

Steps To Reproduce

Run original sample created by dotnet.exe new blazorserver --name BlazorServerTemplate --output . -f net7.0 --auth Individual --use-program-main

On top right click on “Login” which is <a href="Identity/Account/Login">Log in</a> in LoginDisplay.razor.

Wait a minute (or maybe 2) then 2 errors are logged to console (or external logging apps like SEQ):

fail: Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager[4]
      Navigation failed when changing the location to https://localhost:7206/Identity/Account/Login?returnUrl=~/counter
      System.Threading.Tasks.TaskCanceledException: A task was canceled.
         at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
         at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
         at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass13_0.<<NavigateToCore>g__PerformNavigationAsync|0>d.MoveNext()
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'XaCjYqsnL_QC9xVVeKm9IEojYbj1uBcoSgjuyHwtR7U'.
      System.Threading.Tasks.TaskCanceledException: A task was canceled.
         at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
         at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
         at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass13_0.<<NavigateToCore>g__PerformNavigationAsync|0>d.MoveNext()

Exceptions (if any)

TaskCancelledException

.NET Version

7.0.0

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:4
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Schtailiancommented, Feb 13, 2023

@springy76 Sorry, yea you totally write. I was to impatient with intellisense 🙉 it’s like in your example but with context instead of content.

<NotAuthorized Context="authState">
    @if (!IsAuthenticated(authState))
1reaction
springy76commented, Feb 13, 2023

@Schtailian just a side note regarding your code snippet: Do not use the Result property of Tasks to “await” a task, all sorts of deadlocks might happen using such code. The NotAuthorized renderfragment already transports the awaited AuthenticationState by context variable, just pass it around:

                <NotAuthorized Content="authState">
                    @if (!IsAuthenticated(authState))
Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >
c# - How to disable "Attempting to reconnect to the server" ...
Blazor server retains old in-memory client circuits for a default of 3 minutes, which are then torn down, and a 1 minute timeout...
Read more >
Blazor Best Practices: Handling Errors
Errors are likely to occur, the question is how to handle them. Let's take a look at best practices in handling them in...
Read more >
How to Build and Secure Web Applications with Blazor
Learn how to build client-side Web apps using Blazor and how to secure them with Auth0 authentication and authorization features.
Read more >
Adding authentication to a Blazor Server app using Auth0
In this post I show how to add authentication to a Blazor Server ... Using an external identity provider (such as Auth0) is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found