Repository navigation
fix(@angular/ssr): log errors thrown while destroying the platform - #34777
Merged
alan-agius4 merged 1 commit intoNov 24, 2026
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request wraps the platform destruction logic in a try-catch block within asyncDestroyPlatform to catch and log any errors thrown by destroy hooks, preventing them from escaping the macrotask and causing uncaught exceptions. Additionally, a unit test has been added to verify this behavior. There are no review comments, and the changes look solid, so I have no feedback to provide.
An error thrown by a destroy hook escaped the timer that destroys the platform and could terminate the server process. It is now logged. Fixes angular#34754
SkyZeroZx
force-pushed
the
fix/ssr-destroy-platform-uncaught-error
branch
from
November 23, 2026 18:48
e9479a4 to
f32d7cb
Compare
4 of 5 tasks
alan-agius4
approved these changes
Nov 24, 2026
4 of 5 tasks
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a destroy hook throws while the platform is being destroyed, the error escapes the
setTimeoutinasyncDestroyPlatform()and ends the process on servers that useAngularAppEngine. #34768 added atry/finallythere, but that still lets the error through.It doesn't matter whether the component is routed or not. A component that creates a subscription once an HTTP call answers ends the process if the visitor leaves before the answer:
A routed component behind an HTTP resolver only needs a plain subscribe. In a zoneless app, if the request is aborted right as the resolver answers, the component is destroyed before its first change detection and
ngOnDestroyruns withoutngOnInit:The error is now caught and logged. angular/angular#72139 also catches it in the
@angular/platform-servercopy. Here it is logged instead of rejected, since nothing awaits the destroy.Related to #34754