Skip to content

Better diagnostics/information for circular DI dependencies in Blazor WebAssembly #43866

@Webreaper

Description

@Webreaper

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I have a bunch of scoped services in my Blazor WebAssembly app, and inadvertently added a cyclic dependency between two services:

  • Service A injects Service B in its constructor
  • Service B injects Service C in its constructor
  • Service C injects Service A in its constructor

When I launched my WASM app, after the loading progress bar, the app just hung. There was no logging, no information in the Chrome dev tools console, no exception, nothing - it just hung with no clue as to what was wrong. Luckily, after spending a bit of time looking at the commit I realised my mistake, but it would be useful if there were some clues for a developer. I think the lack of logging in DevTools is due to an infinite loop in the WebAssembly, meaning that the whole browser tab locks up.

Describe the solution you'd like

The page should fail to load with a more meaningful error/exception indicating a cyclic DI dependency, so it becomes immediately obvious where the eproblem lies.

Additional context

I don't think it makes a difference, but this issue was found running the WebAssembly app in Chrome, on MacOS, and the app was built with .Net 7 Preview 7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onegood first issueGood for newcomers.help candidateIndicates that the issues may be a good fit for community to help with. Requires work from eng. team

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions