Skip to content

Handle synchronous exceptions from partial #16679

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

Merged
merged 2 commits into from
Nov 1, 2019

Conversation

ryanbrandenburg
Copy link
Contributor

Fixes #15367.

@ryanbrandenburg
Copy link
Contributor Author

@Pilchie for 3.1 askmode.

Copy link
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a couple of additional places where MVC calls the sync dispose on these types:

^ Not exhaustive. I just searched for CreateWriter on GitHub. We should be able to just turn them all into await usings without much ceremony. I don't think we necessarily need a test for every one of these cases.

@@ -0,0 +1 @@
@(new TagHelpersWebSite.MyHtmlContent(Html))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this just use @Html.Partial("_Test")? I'm not sure if the extra indirection is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra indirection seems to be necessary. Tested it out and we don't get the Synchronous complain otherwise.

@@ -12,8 +12,11 @@

<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc" />
<Reference Include="Microsoft.AspNetCore.Diagnostics" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we undo changes to this file and the Startup?

@@ -233,7 +233,7 @@ public class ViewExecutor

OnExecuting(viewContext);

using (var writer = WriterFactory.CreateWriter(response.Body, resolvedContentTypeEncoding))
await using (var writer = WriterFactory.CreateWriter(response.Body, resolvedContentTypeEncoding))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fairly easy to write a unit test for this too. Basically we would write a test where the body of the view in https://github.com/aspnet/AspNetCore/blob/master/src/Mvc/Mvc.ViewFeatures/test/ViewExecutorTest.cs#L94-L97 throws and the test ensures that MVC does not perform a synchronous write to the HTTP response stream.

@Pilchie
Copy link
Member

Pilchie commented Oct 30, 2019

Approved for 3.1.0-Preview3

@Pilchie Pilchie added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Oct 31, 2019
@ryanbrandenburg
Copy link
Contributor Author

🆙📅

@ryanbrandenburg
Copy link
Contributor Author

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact [email protected].

I've triaged the above build. I've created/commented on the following issue(s)
https://github.com/aspnet/AspNetCore-Internal/issues/3100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants