fix: move hierarchy set after comp host resolution

This commit is contained in:
Kamil Myśliwiec
2026-02-16 11:03:41 +01:00
parent d37c2664b6
commit 953569a0af
3 changed files with 10 additions and 9 deletions

View File

@@ -122,11 +122,11 @@ describe('OnApplicationBootstrap', () => {
const parent = module.get(AHost);
const composition = module.get(Composition);
expect(composition.onApplicationBootstrap).toHaveBeenCalledBefore(
expect(child.onApplicationBootstrap).toHaveBeenCalledBefore(
parent.onApplicationBootstrap,
);
expect(parent.onApplicationBootstrap).toHaveBeenCalledBefore(
child.onApplicationBootstrap,
composition.onApplicationBootstrap,
);
});
});

View File

@@ -150,9 +150,9 @@ describe('OnModuleInit', () => {
const child = module.get(A);
const parent = module.get(AHost);
const composition = module.get(Composition);
expect(composition.onModuleInit).toHaveBeenCalledBefore(
parent.onModuleInit,
expect(child.onModuleInit).toHaveBeenCalledBefore(parent.onModuleInit);
expect(parent.onModuleInit).toHaveBeenCalledBefore(
composition.onModuleInit,
);
expect(parent.onModuleInit).toHaveBeenCalledBefore(child.onModuleInit);
});
});

View File

@@ -339,10 +339,6 @@ export class Injector {
index,
);
if (paramWrapper.hierarchyLevel > depth) {
depth = paramWrapper.hierarchyLevel;
}
/*
* Ensure that all instance wrappers are resolved at this point before we continue.
* Otherwise the staticity of `wrapper`'s dependency tree may be evaluated incorrectly
@@ -362,6 +358,11 @@ export class Injector {
contextId,
effectiveInquirer,
);
if (paramWrapperWithInstance.hierarchyLevel > depth) {
depth = paramWrapperWithInstance.hierarchyLevel;
}
const instanceHost = paramWrapperWithInstance.getInstanceByContextId(
this.getContextId(contextId, paramWrapperWithInstance),
this.getInquirerId(effectiveInquirer),