-
Notifications
You must be signed in to change notification settings - Fork 26.2k
fix(core): call ngOnDestroy for tree-shakeable providers #28943
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
Prior to this change, any provider that was independently resolved using its InjectableDef would not be considered when destroying the module it was requested from. This commit provides a fix for this issue by storing the resolved provider in the module's list of provider definitions. Fixes angular#28927
This test verifies that Ivy's module injector does not suffer from angular#28927 to prevent regressing on this behavior going forward.
@@ -109,7 +109,7 @@ export function resolveNgModuleDep( | |||
} else if ( | |||
(injectableDef = getInjectableDef(depDef.token)) && targetsModule(data, injectableDef)) { | |||
const index = data._providers.length; | |||
data._def.providersByKey[depDef.tokenKey] = { | |||
data._def.providers[index] = data._def.providersByKey[depDef.tokenKey] = { |
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.
I believe this can not make data._def.providers
sparse, as the indices should be aligned. I'd like a second opinion on this though :)
/cc @alxhub |
Prior to this change, any provider that was independently resolved using its InjectableDef would not be considered when destroying the module it was requested from. This commit provides a fix for this issue by storing the resolved provider in the module's list of provider definitions. Fixes angular#28927 PR Close angular#28943
…ngular#28943) This test verifies that Ivy's module injector does not suffer from angular#28927 to prevent regressing on this behavior going forward. PR Close angular#28943
Prior to this change, any provider that was independently resolved using its InjectableDef would not be considered when destroying the module it was requested from. This commit provides a fix for this issue by storing the resolved provider in the module's list of provider definitions. Fixes angular#28927 PR Close angular#28943
…ngular#28943) This test verifies that Ivy's module injector does not suffer from angular#28927 to prevent regressing on this behavior going forward. PR Close angular#28943
@mhevery @JoostK Any chance of having this PR applied to the 7.2.x release? Given IE11 has trouble reclaiming memory on active observables (which are not cancelled with the takeUntil in ngOnDestroy) this is a really critical issue. Also, switching back all services spread across several libraries (including 3rd party one such as Material) to the forRoot approach is quite a significant amount of work. |
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. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #28927
Prior to this change, any provider that was independently resolved using
its InjectableDef would not be considered when destroying the module it
was requested from.
What is the new behavior?
This commit provides a fix for this issue by storing
the resolved provider in the module's list of provider definitions.
Additionally, a test for Ivy's module injector was added to prevent
regressing on this behavior going forward.
Does this PR introduce a breaking change?