Skip to content

Uncaught Error: ASSERTION ERROR: NodeInjector must have some connection to the module injector tree #55137

@sd-git

Description

@sd-git

Is this a bug report or a feature request?

  • Bug Report
  • Feature Request

Please provide the steps to reproduce the issue [Bug Report only]

  • Install Angular 17.3.2
  • Create minimal app example provided below
  • Run dev instance ('ng serve')
  • Open Angular Devtool + dev console
  • Refresh the app page and see runtime exception + missing components in 'Components' tab of Angular devtool

Two conditions need to be met for error to happen - child component need to import CommonModule and ChildComponent needs to be used inside @defer block.

Minimal example code to reproduce:

@Component({
  selector: 'app-childcomponent',
  standalone: true,
  imports: [CommonModule],
  template: `<div>Child component</div>`,
})
export class ChildComponent {
}

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [ChildComponent],
  template: `
    <div>AppComponent</div>
    @defer (on viewport) {
      <app-childcomponent/>
    } @placeholder () {
      <div>Placeholder</div>
    }
  `,
})
export class AppComponent {
}

This example throws runtime exception. If we remove CommonModule import from ChildComponent there is no runtime exceptions and everything is working as expected.

Please provide the expected behavior vs the actual behavior you encountered [Bug Report only]

No runtime exception

Please provide a screenshot if possible [Bug Report only]

No response

Please provide the exception or error you saw [Bug Report only]

Uncaught Error: ASSERTION ERROR: NodeInjector must have some connection to the module injector tree
    at throwError2 (core.mjs:537:11)
    at getModuleInjectorOfNodeInjector (core.mjs:30638:9)
    at getInjectorResolutionPathHelper (core.mjs:30528:40)
    at getInjectorResolutionPathHelper (core.mjs:30540:9)
    at Object.getInjectorResolutionPath [as ɵgetInjectorResolutionPath] (core.mjs:30516:5)

Is this a browser-specific issue? If so, please specify the device, browser, and version. [Bug Report only]

Exist in both Chrome and Firefox

Description [Feature Request only]

No response

Proposed solution [Feature Request only]

No response

Alternatives considered [Feature Request only]

No response

Metadata

Metadata

Assignees

Labels

P2The issue is important to a large percentage of users, with a workaroundarea: devtoolsbugstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions