-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Pause and resume Blazor applications #27576
Copy link
Copy link
Closed
Labels
Priority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutUser StoryA single user-facing feature. Can be grouped under an epic.A single user-facing feature. Can be grouped under an epic.affected-mostThis issue impacts most of the customersThis issue impacts most of the customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsdesign-proposalThis issue represents a design proposal for a different issue, linked in the descriptionThis issue represents a design proposal for a different issue, linked in the descriptionenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-circuit-lifecycleIssues to do with blazor server lifecycle eventsIssues to do with blazor server lifecycle eventsseverity-majorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Metadata
Metadata
Assignees
Labels
Priority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutUser StoryA single user-facing feature. Can be grouped under an epic.A single user-facing feature. Can be grouped under an epic.affected-mostThis issue impacts most of the customersThis issue impacts most of the customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsdesign-proposalThis issue represents a design proposal for a different issue, linked in the descriptionThis issue represents a design proposal for a different issue, linked in the descriptionenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-circuit-lifecycleIssues to do with blazor server lifecycle eventsIssues to do with blazor server lifecycle eventsseverity-majorThis label is used by an internal toolThis label is used by an internal tool
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
Enable the ability to "pause" a blazor application and enable components and services within a Blazor application to persist their state when the application is being "shut down" and enable a mechanism to retrieve and restore that state afterwards.
Motivation and goals
Today it is very hard to do prerendering without having the content flash on the page due to the fact that a regular component will render multiple times during an asynchronous code path like retrieving data from a service or datase and produce an intermediate render without content that will quickly replace the content on the rendered page to be followed by the actual content afterwards.
That experience is desirable when the application is not prerendering so as to be able to show content quickly to users, but it's jarring when prerendering is enabled. The guidance that we give our users is to compute all the state of the application ahead of time and pass it down to the root component as a parameter, with the idea of avoiding any asynchronous code paths when the state is available.
This has several drawbacks, like the fact that users need to extract complicated logic out of their blazor application to be run outside of the application context and avoid asynchronous code paths on their code which are very easy to introduce.
The idea is that when we prerender the application we "pause" the application and "persist" the state of components that opt-in into it. We marshal that state to the client and when the app "resumes" we make that state available for components that opted-in on to the feature.
This enables application authors to preserve all the state of their components, like data that was retrieved from a database and ensure that they can produce a deterministic render that is equivalent to content they prerendered on the server.
In addition to that, this same mechanism can be used within server-side Blazor to empower customers to "pause" Blazor server applications and resume them at a later point, for example when there is no activity within a circuit for a given period of time or when a server is experiencing heavy load, enabling better resource management.
In scope
Out of scope
Risks / unknowns
TBD
Examples