nestjs/nest · error · CircularDependencyException
A circular dependency has been detected inside "${wrapper.na
Error message
A circular dependency has been detected inside "${wrapper.name}". Please, make sure that each side of a bidirectional relationships are decorated with "forwardRef()". Note that circular relationships between custom providers (e.g., factories) are not supported since functions cannot be called more than once. What it means
Error "A circular dependency has been detected inside "${wrapper.name}". Please, make sure that each side of a bidirectional relationships are decorated with "forwardRef()". Note that circular relationships between custom providers (e.g., factories) are not supported since functions cannot be called more than once." thrown in nestjs/nest.
Source
Thrown at packages/core/injector/injector.ts:155
public async loadInstance<T>(
wrapper: InstanceWrapper<T>,
collection: Map<InjectionToken, InstanceWrapper>,
moduleRef: Module,
resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT },
) {
const inquirerId = this.getContextInquirerId(resolutionContext);
const instanceHost = wrapper.getInstanceByContextId(
this.getContextId(resolutionContext.contextId, wrapper),
inquirerId,
);
if (instanceHost.isPending) {
const settlementSignal = wrapper.settlementSignal;
if (
resolutionContext.inquirer &&
settlementSignal?.isCycle(resolutionContext.inquirer.id)
) {
throw new CircularDependencyException(`"${wrapper.name}"`);
}
return instanceHost.donePromise!.then((err?: unknown) => {
if (err) {
throw err;
}
});
}
const settlementSignal = this.applySettlementSignal(instanceHost, wrapper);
const token = wrapper.token || wrapper.name;
const { inject } = wrapper;
const targetWrapper = collection.get(token);
if (isUndefined(targetWrapper)) {
throw new RuntimeException();
}
if (instanceHost.isResolved) {View on GitHub (pinned to 39fbddae51)
When it happens
Trigger: Thrown at packages/core/injector/injector.ts:152 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nestjs/nest@39fbddae51 (2026-08-21).
Data as JSON: /api/errors/f322ad50e428daa4.
Report an issue: GitHub.