Skip to content

[Blazor] Custom CircuitHandler latency breaks WS connection on navigation #59657

Open
@garrettlondon1

Description

@garrettlondon1

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

namespace Microsoft.AspNetCore.Components.Server.Circuits;


public class BlazorCircuitHandler() : CircuitHandler
{
    public override async Task OnCircuitOpenedAsync(Circuit circuit, CancellationToken cancellationToken)
    {
        await Task.Delay(2000);
        await base.OnCircuitOpenedAsync(circuit, cancellationToken);
    }

    public override async Task OnCircuitClosedAsync(Circuit circuit, CancellationToken cancellationToken)
    {
        await base.OnCircuitClosedAsync(circuit, cancellationToken);
    }
}

A lot of people use custom Blazor Server CircuitHandler implementations for initializing user state, connecting to SignalR Hubs, etc.

As seen in the video below, if you load a page with an InteractiveServer component, and navigate away before the circuit is opened, the whole circuit breaks. Thus, the whole app breaks.

Expected Behavior

This would be solved with #55127, because enhanced navigation would reopen the broken connection.

Steps To Reproduce

Add custom circuit handler implementation to services

Screen.Recording.2024-12-30.at.2.03.27.AM.mov

Exceptions (if any)

No response

.NET Version

9.0.100

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-blazorIncludes: Blazor, Razor Componentsinvestigate

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions