Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(@angular/ssr): handle platform destruction during rendering #32263

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
arturovt wants to merge 1 commit into angular:main
base: main
Choose a base branch
Loading
from arturovt:fix/angular_ssr_self_destroy

Conversation

@arturovt
Copy link
Contributor

@arturovt arturovt commented Jan 10, 2026

Fixes crash when platform/app destroys itself during the bootstrapping and stabilization phase. Previously, the code would call applicationRef.injector without checking if the platform was destroyed, resulting in: "Error: Injector has already been destroyed"

This can occur when:

  • Component constructor calls inject(PlatformRef).destroy()
  • AbortSignal triggers during request handling
  • APP_INITIALIZER rejects and causes cleanup
  • Custom guard/resolver logic destroys the platform

Solution: Check applicationRef.destroyed after whenStable() and return error state instead of accessing destroyed injector.

Test: Added test case that destroys app in component constructor to verify graceful handling of this edge case.

@arturovt arturovt force-pushed the fix/angular_ssr_self_destroy branch 2 times, most recently from 366b0fc to 88127de Compare January 12, 2026 17:53
@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Jan 13, 2026
Fixes crash when platform/app destroys itself during the bootstrapping and
stabilization phase. Previously, the code would call `applicationRef.injector`
without checking if the platform was destroyed, resulting in:
"Error: Injector has already been destroyed"
This can occur when:
- Component constructor calls `inject(PlatformRef).destroy()`
- AbortSignal triggers during request handling
- APP_INITIALIZER rejects and causes cleanup
- Custom guard/resolver logic destroys the platform
Solution: Check `applicationRef.destroyed` after `whenStable()` and return error
state instead of accessing destroyed injector.
Test: Added test case that destroys app in component constructor to
verify graceful handling of this edge case.
@alan-agius4 alan-agius4 force-pushed the fix/angular_ssr_self_destroy branch from 88127de to 02575d6 Compare January 13, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@alan-agius4 alan-agius4 alan-agius4 approved these changes

Assignees

No one assigned

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/ssr target: patch This PR is targeted for the next patch release

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /