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

Streaming rendering and server buffering 8.0 #30504

Closed
guardrex opened this issue Sep 27, 2023 · 5 comments
Closed

Streaming rendering and server buffering 8.0 #30504

guardrex opened this issue Sep 27, 2023 · 5 comments

Comments

@guardrex
Copy link
Collaborator

Per dotnet/aspnetcore#50915 (comment)


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added Blazor Source - Docs.ms Docs Customer feedback via GitHub Issue labels Sep 27, 2023
@guardrex guardrex changed the title Streaming rendering and server buffering Streaming rendering and server buffering 8.0 Sep 27, 2023
@guardrex guardrex added Pri1 doc-enhancement 8.0 .NET 8 and removed Source - Docs.ms Docs Customer feedback via GitHub Issue labels Sep 27, 2023
@iphdav
Copy link

iphdav commented Sep 28, 2023

@guardrex I wanted to add a few comments for you to consider when writing up the documents.

I was putting together a blazor streaming rendering demo and decided to have it obtain data to display on the page from a separate minimal API that streamed back data using IAsyncEnumerable.

It worked perfectly locally, but when deployed to an Azure Web App, even my minimal API appeared to not be streaming. I was not sure the exact backend architecture of Azure (YARP respone caching, etc), but noticed if I added this after each items was yield returned (within the IAsyncEnumerable):
await context.Response.Body.FlushAsync();
It did correctly stream when deployed to Azure. Flushing the response buffer was not needed when running locally on Kestrel.

It would be interesting if this customer did the same thing in his streaming blazor project to see if it streamed correctly for his particular hosting provider when flushing the buffer after each async update to his page (when streaming rendering the response).

But if you are writing up the documents, maybe just include some general comments and suggestions including configuring the web server, but also flushing the response as shown above.

@iphdav
Copy link

iphdav commented Sep 28, 2023

@guardrex I think in RC2, the HttpContext will be registered globally as a CascadingParameter. At that point, I would be interesting to document this as a potential solution to caching (compared to the default template).

First the component would need to inject the HttpContext using the new technique (which will not work until RC2):

[CascadingParameter] HttpContext Ctx;

In the demo project template, where there is a delay awaited, to add flushing the buffer like this:

await Task.Delay(2000);
await Ctx?.Response.Body.FlushAsync();

It would be interesting to check if this worked, and include this in the docs for Azure (etc) if it does work.

@guardrex
Copy link
Collaborator Author

Thanks ... I'll take a look in detail when I reach this.

It could take a little while tho ... I'm buried in higher priority .NET 8 doc work right now 🗻⛏️😅. I'll reach this prior to RTM.

@guardrex
Copy link
Collaborator Author

guardrex commented Oct 2, 2023

That PR addressed one aspect of this. I'll circle around in a bit to deal with the additional items.

@guardrex
Copy link
Collaborator Author

Closing as fixed by #30538.

@iphdav ... I moved your remarks to a new issue, and I'll ping engineering to take a look at your remarks as soon as I can and when they're free.

@github-project-automation github-project-automation bot moved this from 8.0 to Done in Blazor.Docs Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants