# AUR0003

### **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:

  ```typescript
  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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aurelia.io/developer-guides/error-messages/0001-to-0023/aur0003.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
