Skip to content

Critical bug in version 19.2.12 prevents application from start #61644

Closed

Description

@ZixZux

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

PR #61354 introduces a critical bug.

The application can't be started at all, the error occurs: "RuntimeError: NG0200: Circular dependency in DI detected for _ApplicationRef. Find more at https://angular.dev/errors/NG0200".

It seems the source of the problem is the code: private readonly appRef = inject(ApplicationRef);

Please provide a link to a minimal reproduction of the bug

The application is configured with provideHttpClient( withFetch(), withInterceptorsFromDi() ).

Exception occurs in method hydrate(token, record, flags) while resolving ApplicationRef in the FetchBackend class:

if (record.value === CIRCULAR) {
  throwCyclicDependencyError(stringify(token));

The token here is the "class _ApplicationRef" and the record is the "{ factory: ƒ ApplicationRef_Factory(ngFactoryType), ... }".

Please provide the exception or error you saw

RuntimeError: NG0200: Circular dependency in DI detected for _ApplicationRef. Find more at https://angular.dev/errors/NG0200
    at throwCyclicDependencyError (core.mjs:978:9)
    at R3Injector.hydrate (core.mjs:2238:9)
    at R3Injector.get (core.mjs:2121:23)
    at injectInjectorOnly (core.mjs:1111:28)
    at ɵɵinject (core.mjs:1117:40)
    at inject (core.mjs:1202:10)
    at <instance_members_initializer> (module-BQ-7fJZl.mjs:1620:12)
    at new _FetchBackend (module-BQ-7fJZl.mjs:1612:1)
    at Object.FetchBackend_Factory [as factory] (module-BQ-7fJZl.mjs:1832:12)
    at core.mjs:2243:35
    at runInInjectorProfilerContext (core.mjs:881:5)
    at R3Injector.hydrate (core.mjs:2242:11)
    at R3Injector.get (core.mjs:2121:23)
    at injectInjectorOnly (core.mjs:1111:28)
    at ɵɵinject (core.mjs:1117:40)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.2.12                                                                                                                                                                                               Node: 24.1.0 (Unsupported)                                                                                                                                                                                         Package Manager: npm 11.4.1                                                                                                                                                                                        OS: win32 x64                                                                                                                                                                                                                                                                                                                                                                                                                         Angular: 19.2.12                                                                                                                                                                                                   ... animations, cli, common, compiler, compiler-cli, core, forms                                                                                                                                                   ... platform-browser, router                                                                                                                                                                                                                                                                                                                                                                                                          Package                         Version                                                                                                                                                                            ---------------------------------------------------------                                                                                                                                                          @angular-devkit/architect       0.1902.12                                                                                                                                                                          @angular-devkit/build-angular   19.2.12                                                                                                                                                                            @angular-devkit/core            19.2.12                                                                                                                                                                            @angular-devkit/schematics      19.2.12                                                                                                                                                                            @schematics/angular             19.2.12                                                                                                                                                                            rxjs                            7.8.2                                                                                                                                                                              typescript                      5.8.3                                                                                                                                                                              zone.js                         0.15.1

Anything else?

This is the regression, because prior to the version 19.2.12 application started successfully.

Activity

  1. thePunderWoman commented on May 23, 2025

    @thePunderWoman
    Contributor

    @ZixZux This needs a minimal reproduction in order for us to look deeper. Please create a stackblitz and link it here.

  2. added
    needs reproduction
    area: common
    on May 23, 2025
  3. added this to the Backlog milestone on May 23, 2025
  4. ZixZux commented on May 23, 2025

    @ZixZux
    Author

    @ZixZux This needs a minimal reproduction in order for us to look deeper. Please create a stackblitz and link it here.

    I've described what is happened in the section "Please provide a link to a minimal reproduction of the bug".

    Once more: the bug doesn't exist before PR #61354.

  5. thePunderWoman commented on May 23, 2025

    @thePunderWoman
    Contributor

    @ZixZux Description is not enough. We need a functioning reproduction of the bug to dig through. Please create that for us otherwise this is not actionable.

  6. JeanMeche commented on May 23, 2025

    @JeanMeche
    Member

    The minimal repro:

    @Component({
      selector: 'app-root',
      template: ``,
    })
    export class App {}
    
    export class Handler {
      http = inject(HttpClient);
    }
    
    bootstrapApplication(App, {
      providers: [
        provideHttpClient(withFetch()),
        { provide: ErrorHandler, useClass: Handler },
      ],
    });
    
  7. arturovt commented on May 23, 2025

    @arturovt
    Contributor

    @JeanMeche fine, I'll inject it lazily then

  8. added 2 commits that reference this issue on May 23, 2025
    eadde19
    2a26e9c
  9. ZixZux commented on May 23, 2025

    @ZixZux
    Author

    The minimal repro:

    @Component({
      selector: 'app-root',
      template: ``,
    })
    export class App {}
    
    export class Handler {
      http = inject(HttpClient);
    }
    
    bootstrapApplication(App, {
      providers: [
        provideHttpClient(withFetch()),
        { provide: ErrorHandler, useClass: Handler },
      ],
    });
    

    Thanks!

  10. added 3 commits that reference this issue on May 23, 2025
    3d8f087
    15baa5b
    82979fa
  11. added 2 commits that reference this issue on May 23, 2025
    aa7190d
    2c876b4
  12. added a commit that references this issue on May 23, 2025
    abcb865
  13. ZixZux commented on May 26, 2025

    @ZixZux
    Author

    btw, why angular CI/CD doesn't have such a simple smoke/sanity tests?..

  14. JeanMeche commented on May 26, 2025

    @JeanMeche
    Member

    This could be seen as an edge case. The circular injection required 3 specific pieces.
    Also because the root cause has already been solved on v20, we couldn't not leverage the google code base to test this.

    Any way, we added a test case for it.

  15. ZixZux commented on May 26, 2025

    @ZixZux
    Author

    "The circular injection required 3 specific pieces."

    I'm sure it's the key marker to have such tests initially...

  16. wartab commented on May 26, 2025

    @wartab
    Contributor

    Angular is an open source project, feel free to contribute tests you feel are missing.

  17. ZixZux commented on May 26, 2025

    @ZixZux
    Author

    it's just very strange to hear (put it mildly) that using withFetch() and ErrorHandler "could be seen as an edge case"...

    i'm sure majority applications using these artifacts.

  18. angular-automatic-lock-bot commented on Jun 26, 2025

    @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.

  19. locked and limited conversation to collaborators on Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: commonneeds reproduction

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions