From 953569a0afb0d6fda97230ebb5b6ff93f500108a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20My=C5=9Bliwiec?= Date: Mon, 16 Feb 2026 11:03:41 +0100 Subject: [PATCH] fix: move hierarchy set after comp host resolution --- integration/hooks/e2e/on-app-boostrap.spec.ts | 4 ++-- integration/hooks/e2e/on-module-init.spec.ts | 6 +++--- packages/core/injector/injector.ts | 9 +++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/integration/hooks/e2e/on-app-boostrap.spec.ts b/integration/hooks/e2e/on-app-boostrap.spec.ts index baab8a8d4..79acea4c7 100644 --- a/integration/hooks/e2e/on-app-boostrap.spec.ts +++ b/integration/hooks/e2e/on-app-boostrap.spec.ts @@ -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, ); }); }); diff --git a/integration/hooks/e2e/on-module-init.spec.ts b/integration/hooks/e2e/on-module-init.spec.ts index 3e9eb7879..a1113bd68 100644 --- a/integration/hooks/e2e/on-module-init.spec.ts +++ b/integration/hooks/e2e/on-module-init.spec.ts @@ -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); }); }); diff --git a/packages/core/injector/injector.ts b/packages/core/injector/injector.ts index faa1c0939..d487b5188 100644 --- a/packages/core/injector/injector.ts +++ b/packages/core/injector/injector.ts @@ -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),