toeverything/AFFiNE · error

Could not find block with id ${id}

Error message

Could not find block with id ${id}

What it means

Warning logged in Store's `_onBlockAdded` when the yjs Y.Map `_yBlocks` contains no entry for the block id being added — the store was notified of a block (via subscription or init) that does not exist in the underlying yjs document, usually a race or out-of-sync update. The add is skipped; no block model is created for that id.

Source

Thrown at blocksuite/framework/store/src/model/store/store.ts:656

    const blockModel =
      typeof block === 'string' ? this.getBlock(block)?.model : block;
    if (!blockModel) return null;

    const index = parent.children.indexOf(blockModel);
    if (index === -1) return null;

    return fn(parent, index);
  }

  private _onBlockAdded(id: string, isLocal: boolean, init: boolean) {
    try {
      if (id in this._blocks.peek()) {
        return;
      }
      const yBlock = this._yBlocks.get(id);
      if (!yBlock) {
        console.warn(`Could not find block with id ${id}`);
        return;
      }

      const options: BlockOptions = {
        onChange: (block, key, isLocal) => {
          if (key) {
            block.model.propsUpdated.next({ key });
          }

          this.slots.blockUpdated.next({
            type: 'update',
            id,
            flavour: block.flavour,
            props: { key },
            isLocal,
          });
        },
      };

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Verify the block id exists in the store before access.
  2. The block may have been deleted; refresh the reference.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Triggered when the store handles a block-added event for an id that has no corresponding YBlock in the underlying Yjs doc, so the block is not instantiated.

Common situations: Occurs with inconsistent or corrupted doc state, e.g. during sync races. Usually harmless; if blocks go missing, reload the doc to resync state.


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