fix(core): avoid eager providers re-initialization (#23559)
Fix a corner case where eager providers were getting constructed twice if the provider was requested before the initialization of the NgModule is complete. PR Close #23559
This commit is contained in:

committed by
Igor Minar

parent
5b96078624
commit
0c6dc45c85
@ -68,7 +68,10 @@ export function initNgModule(data: NgModuleData) {
|
||||
for (let i = 0; i < def.providers.length; i++) {
|
||||
const provDef = def.providers[i];
|
||||
if (!(provDef.flags & NodeFlags.LazyProvider)) {
|
||||
providers[i] = _createProviderInstance(data, provDef);
|
||||
// Make sure the provider has not been already initialized outside this loop.
|
||||
if (providers[i] === undefined) {
|
||||
providers[i] = _createProviderInstance(data, provDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user