toeverything/AFFiNE · error · BlockSuiteError

GfxBlockElementError

GfxBlockElementError

Error message

Frame model is not found

What it means

Identical wrapping to the single-get path, but raised while provider.getAll(identifier) instantiates each registered variant: one variant's factory failed to resolve its own dependency, and the Resolver attributes the failure to the whole getAll identifier with the failing inner target named in the message. getAll builds every variant eagerly, so one broken variant poisons the entire map.

Solutions

  1. Register the missing dependency named as target so every variant can construct
  2. Remove the broken variant if unneeded: framework.override(Identifier('brokenVariant'), null) removes it from the registry
  3. If partial results are acceptable, wrap getAll in try-catch on MissingDependencyError, or resolve variants individually with getOptional and skip failures

Example fix

// before
fw.impl(Storage('local'), LocalStorage);
fw.impl(Storage('session'), SessionStorage); // SessionStorage dep missing
provider.getAll(Storage); // Missing dependency ... in creating [Storage]

// after
fw.service(SessionStorage, [SessionStore]); // register the variant's dependency
provider.getAll(Storage); // Map { local, session }
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

import { MissingDependencyError } from '.../framework/core/error';

try {
  const all = provider.getAll(Storage);
} catch (err) {
  if (err instanceof MissingDependencyError) {
    // err.target names the missing dep of one variant; register it or remove that variant
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: provider.getAll(Storage) where one variant (e.g. 'session') depends on an identifier that is not registered; a deps entry declared as [[Dep]] (getAll form) while some variant of the resolved identifier assumes infra the host never registered.

Common situations: Extension points where third-party/plugin variants assume host infrastructure that was not set up; partial test fixtures registering only some variants' dependencies; a variant left registered after its dependency module was removed.

Related errors


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/a7ec11917cb7e295. Report an issue: GitHub.

Appendix: source

Thrown at blocksuite/affine/blocks/frame/src/frame-manager.ts:224

    frame.addChildren(childElements);
  }

  private _addFrameBlock(bound: Bound) {
    const surfaceModel = this.gfx.surface as SurfaceBlockModel;
    const props = this.gfx.std
      .get(EditPropsStore)
      .applyLastProps('affine:frame', {
        title: new Text(new Y.Text(`Frame ${this.frames.length + 1}`)),
        xywh: bound.serialize(),
        index: this.gfx.layer.generateIndex(true),
        presentationIndex: this.generatePresentationIndex(),
      });

    const id = this.gfx.doc.addBlock('affine:frame', props, surfaceModel);
    const frameModel = this.gfx.getElementById(id);

    if (!frameModel || !isFrameBlock(frameModel)) {
      throw new BlockSuiteError(
        ErrorCode.GfxBlockElementError,
        'Frame model is not found'
      );
    }

    return frameModel;
  }

  private _watchElementAdded() {
    if (!this.gfx.surface) {
      return;
    }

    const { surface: surfaceModel, doc } = this.gfx;

    this._disposable.add(
      surfaceModel.elementAdded.subscribe(({ id, local }) => {
        const element = surfaceModel.getElementById(id);

View on GitHub (pinned to b4c8548c09)