You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some days ago I was refactoring the code of a healthy server-side blazor app. After some adjustments here and there, I hit debug. To my surprise, this happens:
The process continued to grow until it froze my operating system and crashed with 31 of my 32GB of RAM consumed.
After two days of digging, I finally found out what was causing the issue: a simple @layout MainLayout inside the global _imports.razor file. This caused a recursive and endless component tree.
Of course, it is my fault: I copied some repeated @using and @inject and put together in one _imports file, and this @layout come along. However, this was extremely hard to debug. No breakpoints getting hit; except if I put on the Html.RenderComponentAsync<App> in the _Host file. After hitting F11, the next thing that happens is an OutOfMemoryException. The stack trace showed just the same line of code, and a bunch of framework calls. After two days of frustration, I was starting to think that I was facing this issue.
Describe the solution you'd like
Would be nice if the runtime is somewhat capable of throwing an exception (with a friendly and helpful message) if it detects a overly-deep and recursive tree of components (before the OutOfMemoryException). I can see this problem occurring with more people, in several ways.
The text was updated successfully, but these errors were encountered:
We don't plan to do this as Blazor doesn't check for circular dependencies the same way the C# compiler doesn't check that recursive methods converge, it is in general too expensive or directly intractable.
Some days ago I was refactoring the code of a healthy server-side blazor app. After some adjustments here and there, I hit debug. To my surprise, this happens:
The process continued to grow until it froze my operating system and crashed with 31 of my 32GB of RAM consumed.
After two days of digging, I finally found out what was causing the issue: a simple
@layout MainLayout
inside the global _imports.razor file. This caused a recursive and endless component tree.Of course, it is my fault: I copied some repeated
@using
and@inject
and put together in one _imports file, and this@layout
come along. However, this was extremely hard to debug. No breakpoints getting hit; except if I put on theHtml.RenderComponentAsync<App>
in the _Host file. After hitting F11, the next thing that happens is an OutOfMemoryException. The stack trace showed just the same line of code, and a bunch of framework calls. After two days of frustration, I was starting to think that I was facing this issue.Describe the solution you'd like
Would be nice if the runtime is somewhat capable of throwing an exception (with a friendly and helpful message) if it detects a overly-deep and recursive tree of components (before the OutOfMemoryException). I can see this problem occurring with more people, in several ways.
The text was updated successfully, but these errors were encountered: