AUR0003

Cyclic dependency found: name

Error message

Cyclic dependency found: name

Parameters

Name of the key being resolved

Error explanation

This error occurs when the DI container detects a cycle in the dependency graph. For example, if class A depends on B, and B depends (directly or indirectly) on A, a cycle is formed: A → B → A or A → B → C → A.

This is most commonly encountered with singletons, since the DI system tries to create only one instance and will detect if it is already in the process of constructing the same dependency.

Common causes

  • Two or more classes depend on each other directly or indirectly.

  • A service or plugin introduces a circular dependency.

  • Accidental import cycles in your codebase.

How to fix

  • Refactor your code to break the cycle. For example, extract the shared logic or dependency into a separate service that both classes can depend on.

  • Use a getter or static inject to defer the resolution of the dependency, which can sometimes break the cycle:

    class Circular {
      static get inject() { return [ICircularDep]; }
      constructor(dep) { this.dep = dep; }
    }

Debugging tips

  • Check the stack trace to see the chain of dependencies that led to the cycle.

  • Search your codebase for all places where the involved classes are injected.

  • If using plugins, try disabling them one at a time to isolate the source.

Note

Cyclic dependencies are often a sign that your code could be refactored for better separation of concerns.

Please also note that this error could be caused by a plugin and not your application. After ruling out that the error is not being caused by your code, try removing any registered plugins one at a time to see if the error resolves itself.

Last updated

Was this helpful?