{"record":{"id":"f322ad50e428daa4","repo":"nestjs/nest","slug":"a-circular-dependency-has-been-detected-inside","errorCode":null,"errorMessage":"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.","messagePattern":"A circular dependency has been detected inside \"(.+?)\"\\. 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\\.","errorType":"exception","errorClass":"CircularDependencyException","httpStatus":null,"severity":"error","filePath":"packages/core/injector/injector.ts","lineNumber":155,"sourceCode":"  public async loadInstance<T>(\n    wrapper: InstanceWrapper<T>,\n    collection: Map<InjectionToken, InstanceWrapper>,\n    moduleRef: Module,\n    resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT },\n  ) {\n    const inquirerId = this.getContextInquirerId(resolutionContext);\n    const instanceHost = wrapper.getInstanceByContextId(\n      this.getContextId(resolutionContext.contextId, wrapper),\n      inquirerId,\n    );\n\n    if (instanceHost.isPending) {\n      const settlementSignal = wrapper.settlementSignal;\n      if (\n        resolutionContext.inquirer &&\n        settlementSignal?.isCycle(resolutionContext.inquirer.id)\n      ) {\n        throw new CircularDependencyException(`\"${wrapper.name}\"`);\n      }\n\n      return instanceHost.donePromise!.then((err?: unknown) => {\n        if (err) {\n          throw err;\n        }\n      });\n    }\n\n    const settlementSignal = this.applySettlementSignal(instanceHost, wrapper);\n    const token = wrapper.token || wrapper.name;\n\n    const { inject } = wrapper;\n    const targetWrapper = collection.get(token);\n    if (isUndefined(targetWrapper)) {\n      throw new RuntimeException();\n    }\n    if (instanceHost.isResolved) {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/nestjs/nest/blob/39fbddae51281ca56bf2fed9123d98e61509066c/packages/core/injector/injector.ts#L137-L173","documentation":"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.","triggerScenarios":"Thrown at packages/core/injector/injector.ts:152 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39fbddae51281ca56bf2fed9123d98e61509066c","analyzedAt":"2026-08-21T19:39:39.867Z","contentChangedAt":"2026-08-21T19:39:39.867Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}