-
Notifications
You must be signed in to change notification settings - Fork 27k
fix(platform-server): destroy PlatformRef when error happens duringthe bootstrap() phase
#58135
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
Conversation
|
cc @Platonn |
devversion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @JeanMeche
e3fec9e to
c952f39
Compare
|
Tests are failing 😞 |
… the `bootstrap()` phase (angular#58112) The `bootstrap()` phase might fail e.g. due to an rejected promise in some `APP_INIIALIZER`. If `PlatformRef` is not destroyed, then the main app's injector is not destroyed and therefore `ngOnDestroy` hooks of singleton services is not called on the end (failure) of SSR. This could lead to possible memory leaks in custom SSR apps, if their singleton services' `ngOnDestroy` hooks contained an important teardown logic (e.g. unsubscribing from RxJS observable). Note: I needed to fix by the way another thing too: now we destroy `moduleRef` when `platformInjector` is destroyed - by setting a `PLATFORM_DESTROY_LISTENER` Patch port of angular#58112
c952f39 to
cdad299
Compare
|
This PR was merged into the repository by commit b40875a. The changes were merged into the following branches: 18.2.x |
… the `bootstrap()` phase (#58112) (#58135) The `bootstrap()` phase might fail e.g. due to an rejected promise in some `APP_INIIALIZER`. If `PlatformRef` is not destroyed, then the main app's injector is not destroyed and therefore `ngOnDestroy` hooks of singleton services is not called on the end (failure) of SSR. This could lead to possible memory leaks in custom SSR apps, if their singleton services' `ngOnDestroy` hooks contained an important teardown logic (e.g. unsubscribing from RxJS observable). Note: I needed to fix by the way another thing too: now we destroy `moduleRef` when `platformInjector` is destroyed - by setting a `PLATFORM_DESTROY_LISTENER` Patch port of #58112 PR Close #58135
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The
bootstrap()phase might fail e.g. due to an rejected promise in someAPP_INIIALIZER. IfPlatformRefis not destroyed, then the main app's injector is not destroyed and thereforengOnDestroyhooks of singleton services is not called on the end (failure) of SSR.This could lead to possible memory leaks in custom SSR apps, if their singleton services'
ngOnDestroyhooks contained an important teardown logic (e.g. unsubscribing from RxJS observable).Note: I needed to fix by the way another thing too: now we destroy
moduleRefwhenplatformInjectoris destroyed - by setting aPLATFORM_DESTROY_LISTENERPatch port of #58112