toeverything/AFFiNE · error · ComponentNotFoundError

Component ${stringifyIdentifier(identifier)} not found in co

Error message

Component ${stringifyIdentifier(identifier)} not found in container

What it means

getRaw throws ComponentNotFoundError when no factory exists for the identifier in this scope (and no parent scope supplies it and it is not optional), the DI framework's standard missing-service failure.

Source

Thrown at packages/common/infra/src/framework/core/provider.ts:180

  ) {
    const factory = this.provider.collection.getFactory(
      identifier,
      this.provider.scope
    );
    if (!factory) {
      if (this.provider.parent && !sameScope) {
        return this.provider.parent.getRaw(identifier, {
          sameScope: sameScope,
          optional,
          noCache,
          props,
        });
      }

      if (optional) {
        return undefined;
      }
      throw new ComponentNotFoundError(identifier);
    }

    const runFactory = () => {
      const nextResolver = this.track(identifier);
      try {
        return withContext(() => factory(nextResolver), {
          provider: this.provider,
          props,
        });
      } catch (err) {
        if (err instanceof ComponentNotFoundError) {
          throw new MissingDependencyError(
            identifier,
            err.identifier,
            this.stack
          );
        }
        throw err;

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Register the component's provider before resolving it from the container.
  2. Check the identifier spelling and that the correct module is imported.
  3. Ensure the provider is added to the framework before the resolution happens.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/common/infra/src/framework/core/provider.ts:180 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/52e96b61135b8a58. Report an issue: GitHub.