-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
When updating from Angular 18 to 19 I get a "Circular dependency in DI detected" for ChangeDetectionScheduler which I did not get in Angular 18.
The scenario is a bit complex and uses CDK, but I managed to make a simpler reproduction in StackBlitz. The issue related to using effect in the bootstrapping code. Angular 18 used micro tasks and that made it work. In the StackBlitz in DirectionalityCdkOverride it is possible to get it to run by replacing effect with ɵmicrotaskEffect. This however seems like a hack and I suppose that ɵmicrotaskEffect will not be available in the future.
The scenario
We have our own service for keeping language information including text direction LTR/RTL. We therefore override CDK's Directionality with our own version. We also get the users preference when initializing Angular.
The problem/question
It does not seem like our application has circular dependencies as the error message suggests. Also the message refers to ChangeDetectionScheduler which is a class out of our reach. So maybe the error message is not really applicable/informational for this scenario?
Also is this scenario "illegal" or is it a complex scenario that effect does not handle well?
Thanks
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
Error: NG0200: Circular dependency in DI detected for ChangeDetectionScheduler. Find more at https://angular.dev/errors/NG0200
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 19.0.2
Node: 20.18.0
Package Manager: npm 10.8.2
OS: win32 x64
Angular: 19.0.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1900.2
@angular-devkit/build-angular 19.0.2
@angular-devkit/core 19.0.2
@angular-devkit/schematics 19.0.2
@angular/cli 19.0.2
@schematics/angular 19.0.2
rxjs 7.8.1
typescript 5.6.3
zone.js 0.15.0
Anything else?
To see the error in StackBlitz, open the browsers DevTools console.