Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render Output Invalid: Improve exception message #55374

Open
jessicah opened this issue Apr 26, 2024 · 1 comment
Open

Render Output Invalid: Improve exception message #55374

jessicah opened this issue Apr 26, 2024 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-observability Pillar: Dev Experience
Milestone

Comments

@jessicah
Copy link

throw new InvalidOperationException($"Render output is invalid for component of type '{component.GetType().FullName}'. A frame of type '{invalidFrame.FrameType}' was left unclosed. Do not use try/catch inside rendering logic, because partial output cannot be undone.");

It took me an age to figure out my issue, as the exception wasn't the clearest as I had no try/catch behaviour. Can it also state that using break in a loop can also be a cause for this exception?

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Apr 26, 2024
@mkArtakMSFT
Copy link
Member

Thanks for bringing this up. Breaking mid rendering loop can be problematic (and cause and exception) if the rendered output is not "proper HTML". For example, if you're rendering table rows and break mid rendering, the closing tags for cell/row/table could end up not being rendered and the HTML structure would break.
So for these situations we recommend the customers to render proper closing tags for the context even after breaking.

We will see if we need to expand the exception message with a link to a documentation page, where we can expand more on this issue.

@mkArtakMSFT mkArtakMSFT added feature-observability enhancement This issue represents an ask for new feature or an enhancement to an existing one Pillar: Dev Experience labels Apr 29, 2024
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-observability Pillar: Dev Experience
Projects
None yet
Development

No branches or pull requests

2 participants