-
Notifications
You must be signed in to change notification settings - Fork 27.1k
effect and computed throws circular dependency when ErrorHandler creates effect computed during construction (or one of its dependencies does) #52680
Copy link
Copy link
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimeIssues related to the framework runtimebugcore: reactivityWork related to fine-grained reactivity in the core frameworkWork related to fine-grained reactivity in the core frameworkcross-cutting: signalsstate: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
After upgrade to 17 signal objects not working properly
Injectable({ providedIn: 'root' })
export class PrincipalService {
_loginCompleted = signal<boolean>(false);
_token = signal<string>(null);
user = signal<SessionState>(createInitialSessionState());
user$ = toObservable(this.user);
apiCount = signal<number>(0);
constructor() {
effect(() => {
setTimeout(() => {
this.visible.set(this.apiCount() != 0);
}, 0);
}, {
allowSignalWrites: true
});
}
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Error: NG0200: Circular dependency in DI detected for ErrorHandler. Find more at https://angular.io/errors/NG0200
at throwCyclicDependencyError (core.mjs:292:11)
at R3Injector.hydrate (core.mjs:6158:13)
at R3Injector.get (core.mjs:6033:33)
at effect (core.mjs:14259:35)
at toObservable (rxjs-interop.mjs:48:27)
at new PrincipalService (principal.service.ts:22:25)
at Object.PrincipalService_Factory [as factory] (ɵfac.js:1:1)
at core.mjs:6164:43
at runInInjectorProfilerContext (core.mjs:867:9)
at R3Injector.hydrate (core.mjs:6163:17)
Error: NG0200: Circular dependency in DI detected for ErrorHandler. Find more at https://angular.io/errors/NG0200
at throwCyclicDependencyError (core.mjs:292:11)
at R3Injector.hydrate (core.mjs:6158:13)
at R3Injector.get (core.mjs:6033:33)
at effect (core.mjs:14259:35)
at new FuseProgressBarService (progress-bar.service.ts:24:15)
at Object.FuseProgressBarService_Factory [as factory] (ɵfac.js:1:1)
at core.mjs:6164:43
at runInInjectorProfilerContext (core.mjs:867:9)
at R3Injector.hydrate (core.mjs:6163:17)
at R3Injector.get (core.mjs:6033:33)
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 17.0.0
Node: 18.18.2
Package Manager: npm 9.8.1
OS: darwin x64
Angular: 17.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.1700.0
@angular-devkit/build-angular 17.0.0
@angular-devkit/build-ng-packagr 0.1002.0
@angular-devkit/core 17.0.0
@angular-devkit/schematics 17.0.0
@angular/cdk 16.2.12
@angular/flex-layout 15.0.0-beta.42
@angular/material 16.2.12
@angular/material-moment-adapter 16.2.12
@angular/youtube-player 16.2.12
@schematics/angular 17.0.0
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.2
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimeIssues related to the framework runtimebugcore: reactivityWork related to fine-grained reactivity in the core frameworkWork related to fine-grained reactivity in the core frameworkcross-cutting: signalsstate: has PR