0

I have been converting my Ionic Angular v20.1.4 application over to standalone, and I have had a few Circular dependency errors popup where there were none before.

A couple of others I found a work around (thought I am dead sure there were no circular dependencies), but this one here is perplexing me, and I have no idea how to diagnose why this is happening.

My ng/rx is setup using the old modules, as I cannot get the new provide methods to work for effect in classes (which is what I have), so I have in app.config.ts

importProvidersFrom( StoreModule.forRoot({}), EffectsModule.forRoot([]), StoreModule.forFeature(Constants.vals.featureNames.appState, APP_REDUCER_TOKEN), 

All this was working fine, but adding back one of my service dependencies (see below) has caused the following..

 RuntimeError: NG0200: Circular dependency detected for `StoreFeatureModule`. Find more at https://angular.dev/errors/NG0200 at createRuntimeError (root_effect_scheduler.mjs:895:19) at cyclicDependencyError (root_effect_scheduler.mjs:816:12) at R3Injector.hydrate (root_effect_scheduler.mjs:2147:23) at R3Injector.get (root_effect_scheduler.mjs:2007:33) at R3Injector.retrieve (root_effect_scheduler.mjs:1903:25) at injectInjectorOnly (root_effect_scheduler.mjs:1020:39) at ɵɵinject (root_effect_scheduler.mjs:1032:60) at useValue (root_effect_scheduler.mjs:1755:73) at R3Injector.resolveInjectorInitializers (root_effect_scheduler.mjs:2073:17) at core.mjs:906:31 

I have tracked it down (with no help from the actual error) to a root service that injects a Cordova Network plugin.

So I have the global service

import { Network } from '@awesome-cordova-plugins/network/ngx'; @Injectable({ providedIn: 'root', }) export class NetworkService constructor( private network: Network, <-- remove this and the circular dependency goes away 

Looking on GitHub, from what I can see the Network makes no use of ng/rx, as I expected it didn't.

I do not use this Network anywhere else, I have it encapsulated in my own service, as sown above.

My question is, how can I track down WHY this causes a circular dependency to something completely unrelated, which was not there before going to standalone?

I have look through the call stack, and it is quite hard to follow the logic. How can I diagnose this?

Update

Putting break points in again, I found an error that was not logged to the console...

enter image description here

So I forgot to add the Network back to the providers in `app.config.ts' providers. After I did this, the error has gone.

So, really the error messages is misleading.

6
  • Without a working repro it's a bit hard to say. Also if you update to 20.1 you'll be able to see the cyclic path logged in the error : github.com/angular/angular/pull/50902 Commented Aug 15 at 0:34
  • I should have mentioned, I do have have Angular 20.1.4, where could I see this path? Commented Aug 15 at 0:37
  • Ahh, going back to debugging again, I noticed another error that is not logged, i.e. I was not providing the Network plugin. This error does not appear in the console (I updated the question with call stack). So I did have an error, but the message is very misleading. Commented Aug 15 at 0:48
  • 1
    That's interesing, but unfortunately very hard to investigate without a minimal reproduction (eg on a stackblitz). Commented Aug 15 at 9:00
  • Sometimes these things will only happen in non-minimal (real world) applications which of course are more complex. I will try and get a minimal reproduction of it, so can possibly report it, as soon as time allows (very busy trying to get this conversion standalone and the hurdles finished) Commented Aug 17 at 22:56

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.