{"record":{"id":"368190af81e217a2","repo":"toeverything/AFFiNE","slug":"a-circular-dependency-was-detected-n-stringifyde","errorCode":null,"errorMessage":"A circular dependency was detected.\\n${stringifyDependencyStack(dependencyStack)}","messagePattern":"A circular dependency was detected\\.\\\\n(.+?)","errorType":"exception","errorClass":"CircularDependencyError","httpStatus":null,"severity":"error","filePath":"packages/common/infra/src/framework/core/provider.ts","lineNumber":277,"sourceCode":"      }\n      result.set(variant, service);\n    }\n\n    return result;\n  }\n\n  track(identifier: IdentifierValue): Resolver {\n    const depth = this.depth + 1;\n    if (depth >= 100) {\n      throw new RecursionLimitError();\n    }\n    const circular = this.stack.find(\n      i =>\n        i.identifierName === identifier.identifierName &&\n        i.variant === identifier.variant\n    );\n    if (circular) {\n      throw new CircularDependencyError([...this.stack, identifier]);\n    }\n\n    return new Resolver(this.provider, depth, [...this.stack, identifier]);\n  }\n\n  override dispose(): void {}\n}\n\nexport class BasicFrameworkProvider extends FrameworkProvider {\n  public readonly cache = new ComponentCachePool();\n  public readonly collection: Framework;\n  public readonly eventBus: EventBus;\n\n  disposed = false;\n\n  constructor(\n    collection: Framework,\n    public readonly scope: string[],","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/common/infra/src/framework/core/provider.ts#L259-L295","documentation":"track compares the current resolution stack and throws CircularDependencyError with the full stack when the same identifier/variant is requested again before its factory finished, pinpointing the dependency cycle.","triggerScenarios":"Thrown at packages/common/infra/src/framework/core/provider.ts:277 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Break the circular dependency shown in the printed stack, e.g. by introducing an interface or lazy resolution.","Refactor one side of the cycle to depend on an abstraction instead of the concrete component.","Use a factory or deferred resolution for one of the components in the cycle."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}