Skip to content

Hydration: add a warning when ApplicationRef.isStable doesn't emit true after some time #50285

@AndrewKushnir

Description

@AndrewKushnir

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

Currently, Angular hydration logic depends on the ApplicationRef.isStable on the client for a couple things:

  • when the post-hydration DOM cleanup should happen (to remove all unclaimed DOM segments)
  • when to output hydration stats into a console
  • when the HttpClient cache should no longer be in use

We've received a few requests where hydration stats are not displayed in a console after hydration and in all cases this leads into ApplicationRef.isStable not emitting true. There are various reasons for this and in in vast majority of cases the problems are unrelated to hydration. However, previously this was not "visible" in the app, but with hydration the use of ApplicationRef.isStable increased and it becomes more important to get to the "stable" state.

As a first step to improve the DX, we should add a warning when the app didn't get to the "stable" state after some time (N seconds, N=10?). For this warning it'd be also important to have an error guide page to explain this problem in more details and provide some hints on how to resolve that. We could also use this error guide page to collect more information about use-cases over time.

Relevant code: https://github.com/angular/angular/blob/main/packages/core/src/hydration/api.ts#L162-L183.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: hydrationfeatureIssue that requests a new featurefeature: in backlogFeature request for which voting has completed and is now in the backlogstate: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions