Skip to content

fix(@angular/ssr): check whether injector is destroyed #30738

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arturovt
Copy link
Contributor

In this commit, we check whether the injector is destroyed before calling to envInjector.get. The application might be destroyed and whenStable() would resolve immediately; as thus, calling to injector.get is unsafe and should be guarded.

In this commit, we check whether the injector is destroyed before calling to `envInjector.get`. The application might be destroyed and `whenStable()` would resolve immediately; as thus, calling to `injector.get` is unsafe and should be guarded.
@clydin clydin requested a review from alan-agius4 July 18, 2025 18:05
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 18, 2025
const routerIsProvided = !!envInjector.get(ActivatedRoute, null);
const router = envInjector.get(Router);
const lastSuccessfulNavigation = router.lastSuccessfulNavigation;
const routerIsProvided = destroyed ? false : !!envInjector.get(ActivatedRoute, null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the case when the applicationRef gets destroyed before the rendering phase? Internally in

renderInternal(platformRef, applicationRef)
the environment injector is also required to render the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/ssr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants