Skip to content

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

Closed

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

Activity

  1. added
    area: core
    core: defer
    on Mar 30, 2024
  2. added this to the needsTriage milestone on Mar 30, 2024
  3. added and removed
    area: core
    core: defer
    on Mar 30, 2024
  4. alxhub commented on Mar 30, 2024

    @alxhub
    Member

    This seems to be a devtools issue - I can't reproduce it in JIT or AOT modes in the actual application (the child component renders normally).

    Also, the crash stack trace shows ɵgetInjectorResolutionPath which is a devtools-specific API.

  5. JeanMeche commented on Mar 31, 2024

    @JeanMeche
    Member

    Also tried to reproduce it without success. 17.3.2 & latest pre-release of 18 (next.2).
    Is your devtools up-to-date (1.0.12) ?

  6. sd-git commented on Mar 31, 2024

    @sd-git
    Author

    Yes, devtools is the latest version 1.0.12 (sha d15dca0).
    Also, to make this as isolated as possible, I was able to replicate this in Windows 10 VM installing everything from scatch:

    • Node 18.19.0
    • Angular 17.3.2
    • Angular Devtools 1.0.12
    • Fresh Angular app using ng new + replace app.component.ts with example from this bug's description

    To see console exception you have to open Angular devtool tab in browser's devtools panel first to initialize Angular devtools - until then there are no any exceptions.
    And as @alxhub mentioned, this affects only Angular devtools - application itself seems to be working correctly.

  7. self-assigned this
    on Apr 1, 2024
  8. added
    P2
    on Apr 1, 2024
  9. added a commit that references this issue on Apr 1, 2024
    403004e
  10. modified the milestones: needsTriage, Backlog on Apr 1, 2024
  11. AndrewKushnir commented on Apr 1, 2024

    @AndrewKushnir
    Contributor

    @sd-git thanks for reporting the issue. I was able to reproduce the problem in unit tests and confirmed that only debug APIs used by DevTools were affected. The underlying issue is that PR #55079 introduced a new injector chain configuration, which wasn't handled in the debug util logic. I've created a PR with the proposed fix, see PR #55144.

  12. added a commit that references this issue on Apr 3, 2024
    158ceaf
  13. added a commit that references this issue on Apr 3, 2024
    231e0a3
  14. AndrewKushnir commented on Apr 4, 2024

    @AndrewKushnir
    Contributor

    The fix for this issue was released today as a part of Angular v17.3.3 and is available on NPM. Please let us know if the problem still exists after updating an app to v17.3.3 (no updates to DevTools should be needed).

  15. sd-git commented on Apr 4, 2024

    @sd-git
    Author

    Thanks @AndrewKushnir , minimal example now works as expected, no any errors.

    But in real bigger project I'm now facing new kind of an error with devtools + defer:
    image

    Let me know if it's not clear from the error's screenshot what's happening and I will try to come up with another 'minimal example' to reproduce.
    Probably, it's related to more custom and more complex child components that are used inside of @defer block in real project comparing to this simple example.

  16. angular-automatic-lock-bot commented on May 5, 2024

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  17. locked and limited conversation to collaborators on May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2area: devtoolsbugstate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions