toeverything/AFFiNE · error · CircularDependencyError
A circular dependency was detected.\n${stringifyDependencySt
Error message
A circular dependency was detected.\n${stringifyDependencyStack(dependencyStack)} What it means
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.
Source
Thrown at packages/common/infra/src/framework/core/provider.ts:277
}
result.set(variant, service);
}
return result;
}
track(identifier: IdentifierValue): Resolver {
const depth = this.depth + 1;
if (depth >= 100) {
throw new RecursionLimitError();
}
const circular = this.stack.find(
i =>
i.identifierName === identifier.identifierName &&
i.variant === identifier.variant
);
if (circular) {
throw new CircularDependencyError([...this.stack, identifier]);
}
return new Resolver(this.provider, depth, [...this.stack, identifier]);
}
override dispose(): void {}
}
export class BasicFrameworkProvider extends FrameworkProvider {
public readonly cache = new ComponentCachePool();
public readonly collection: Framework;
public readonly eventBus: EventBus;
disposed = false;
constructor(
collection: Framework,
public readonly scope: string[],View on GitHub (pinned to b4c8548c09)
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.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/common/infra/src/framework/core/provider.ts:277 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/368190af81e217a2.
Report an issue: GitHub.