-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Fix SSR page rendering intermediate state instead of the end state of components #52823
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
Conversation
src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Prerendering.cs
Outdated
Show resolved
Hide resolved
@surayya-MS This approach looks perfect to me. It's reassuring that nothing weird is going on and we just need to extend our use of the same pattern. Thanks for figuring this out! |
...ssets/Components.TestServer/RazorComponents/Components/ChildComponentThatDelaysLoading.razor
Outdated
Show resolved
Hide resolved
...sets/Components.TestServer/RazorComponents/Components/ParentComponentThatDelaysLoading.razor
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
A small tweak to the tests, if you want to make something asynchronous, Task.Yield()
is better than Task.Delay()
it does the same thing and we aren't adding time to the test run (imagine this over 60 tests, it adds 1 minute to the test run, and so on).
As long as we change, the rest looks good.
…onents/Components/ChildComponentThatDelaysLoading.razor Co-authored-by: Javier Calvarro Nelson <[email protected]>
…onents/Components/ParentComponentThatDelaysLoading.razor Co-authored-by: Javier Calvarro Nelson <[email protected]>
… components (dotnet#52823) * finish all non streaming pending tasks before rendering ssr page * fix tests * refactor fix for the tests * call Dispatcher.AssertAccess() in AddPendingTask() * add e2e test * fix post request await all non streaming pending tasks; add e2e test * move NonStreamingPendingTasks class to another file * save WaitForNonStreamingPendingTasks into a variable * Update src/Components/test/testassets/Components.TestServer/RazorComponents/Components/ChildComponentThatDelaysLoading.razor Co-authored-by: Javier Calvarro Nelson <[email protected]> * Update src/Components/test/testassets/Components.TestServer/RazorComponents/Components/ParentComponentThatDelaysLoading.razor Co-authored-by: Javier Calvarro Nelson <[email protected]> --------- Co-authored-by: Javier Calvarro Nelson <[email protected]>
… components (#52823) (#52943) * finish all non streaming pending tasks before rendering ssr page * fix tests * refactor fix for the tests * call Dispatcher.AssertAccess() in AddPendingTask() * add e2e test * fix post request await all non streaming pending tasks; add e2e test * move NonStreamingPendingTasks class to another file * save WaitForNonStreamingPendingTasks into a variable * Update src/Components/test/testassets/Components.TestServer/RazorComponents/Components/ChildComponentThatDelaysLoading.razor * Update src/Components/test/testassets/Components.TestServer/RazorComponents/Components/ParentComponentThatDelaysLoading.razor --------- Co-authored-by: Javier Calvarro Nelson <[email protected]>
Fix SSR page rendering intermediate state instead of the end state of components
The problem was that not all non streaming pending tasks are awaited.
By the time it reaches this line not all non streaming pending tasks are in the list. Later other tasks can be added by child components.
I used a similar technique to correctly await all the non streaming pending tasks that is already is used here.
Same problem when post requests awaits non streaming pending tasks. Not all non streaming pending tasks are in the list. Later other tasks can be added by child components.
Fixes #52131
Fixes #52871