Skip to content

[release/8.0] Fix SSR page rendering intermediate state instead of the end state of components #52943

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

Conversation

surayya-MS
Copy link
Member

@surayya-MS surayya-MS commented Dec 21, 2023

[release/8.0] Fix SSR page rendering intermediate state instead of the end state of components

Manual backport of 52823

Description

This PR fixes SSR page rendering end state of components.
The problem was that non streaming pending tasks were not properly awaiited.

Fixes #52131
Fixes #52871

Customer Impact

Without this change customers will have bad experience with SSR pages because in some cases the intermediate state of the components is rendered in the browser. The end state is never rendered. Example:

Add Child.razor component to the Blazor Web App project:

<div>@childString</div>

@code {
   private string childString = "initial child";

   protected override async Task OnInitializedAsync()
   {
        await Task.Delay(1000);

        childString = "loaded child";
   }

}

Update Home.razor to:

@page "/"

<PageTitle>Home</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.

@if (someProperty)
{
    <Child />
}

@code {
    private bool someProperty;

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        someProperty = await Load();
    }

    private async Task<bool> Load()
    {
        await Task.Delay(1000);

        return true;
    }
}

Run the app. The browser displays:

Welcome to your new app.
initial child

but it should display

Welcome to your new app.
loaded child

Regression?

  • Yes
  • No

[If yes, specify the version the behavior has regressed from]

Risk

  • High
  • Medium
  • Low

This is a minor change. There are e2e tests for this change as well as manual testing was done.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

When servicing release/2.1

  • Make necessary changes in eng/PatchConfig.props

… 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]>
@surayya-MS surayya-MS requested a review from a team as a code owner December 21, 2023 12:39
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Dec 21, 2023
@ghost ghost added this to the 8.0.x milestone Dec 21, 2023
@ghost
Copy link

ghost commented Dec 21, 2023

Hi @surayya-MS. If this is not a tell-mode PR, please make sure to follow the instructions laid out in the servicing process document.
Otherwise, please add tell-mode label.

@surayya-MS surayya-MS added Servicing-consider Shiproom approval is required for the issue and removed area-blazor Includes: Blazor, Razor Components labels Dec 21, 2023
@ghost
Copy link

ghost commented Dec 21, 2023

Hi @surayya-MS. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge.

To learn more about how to prepare a servicing PR click here.

@surayya-MS surayya-MS added the area-blazor Includes: Blazor, Razor Components label Dec 21, 2023
@surayya-MS
Copy link
Member Author

Same problem with Microsoft.AspNetCore.Components.E2ETest.Tests.EventTest.Cancel_CanTrigger test. More details in this comment
#52767 (comment)

@mkArtakMSFT
Copy link
Contributor

Thanks @surayya-MS.
Can you please clarify the customer impact please. In which specific cases customers will not see the final state being rendered? And if that happens, what actually shows up in the browser? Will the updated state be rendered later or will they simply not get the full content that was supposed to be rendered?

Copy link
Contributor

@mkArtakMSFT mkArtakMSFT left a comment

Choose a reason for hiding this comment

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

Approving as the original PR has already been reviewed.

@mkArtakMSFT mkArtakMSFT added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Jan 2, 2024
@ghost
Copy link

ghost commented Jan 2, 2024

Hi @surayya-MS. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed.

@wtgodbe
Copy link
Member

wtgodbe commented Jan 3, 2024

@MackinnonBuck any chance the E2E failures are related to this change?

@wtgodbe
Copy link
Member

wtgodbe commented Jan 3, 2024

/azp run

@wtgodbe
Copy link
Member

wtgodbe commented Jan 3, 2024

Looks like it's unrelated as per Surayya's comment

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@wtgodbe wtgodbe merged commit 148cba6 into dotnet:release/8.0 Jan 4, 2024
@ghost ghost modified the milestones: 8.0.x, 8.0.2 Jan 4, 2024
@ghost ghost added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Jan 4, 2024
@mkArtakMSFT
Copy link
Contributor

@MackinnonBuck any chance the E2E failures are related to this change?

They aren't. I did already confirm that earlier.

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 area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework Servicing-approved Shiproom has approved the issue
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants