toeverything/AFFiNE · error · Error

Failed to get snapshot

Error message

Failed to get snapshot

What it means

commitEditing extracts a snapshot from the editing draft's temp doc via snapshotHelper.getSnapshot; a null result means the snapshot could not be serialized, so the edit cannot be committed and this Error is thrown.

Source

Thrown at packages/frontend/core/src/modules/comment/entities/doc-comment.ts:194

    type: 'comment' | 'reply',
    snapshot: DocSnapshot,
    attachments: CommentAttachment[]
  ): Promise<void> {
    const doc = await this.snapshotHelper.createStore(snapshot);
    if (!doc) {
      throw new Error('Failed to create doc for editing');
    }
    this.editingDraft$.setValue({ id, type, doc, attachments });
  }

  /** Commit current editing draft (if any) */
  async commitEditing(): Promise<void> {
    const draft = this.editingDraft$.value;
    if (!draft) return;

    const snapshot = this.snapshotHelper.getSnapshot(draft.doc);
    if (!snapshot) {
      throw new Error('Failed to get snapshot');
    }

    if (draft.type === 'comment') {
      await this.updateComment(draft.id, {
        snapshot,
        attachments: draft.attachments,
      });
    } else {
      await this.updateReply(draft.id, {
        snapshot,
        attachments: draft.attachments,
      });
    }
    track.$.commentPanel.$.editComment({
      type: draft.type === 'comment' ? 'root' : 'node',
    });
    this.editingDraft$.setValue(null);
    this.revalidate();

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Ensure the comment doc is loaded before requesting a snapshot.
  2. Retry after sync completes.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown in commitEditing when snapshotHelper.getSnapshot returns null for the current editing draft doc, so the edited comment content cannot be serialized back to a snapshot before updating the comment or reply.

Common situations: Occurs when saving an edited comment or reply fails because the editor doc state could not be snapshotted, typically due to a broken draft doc. Dismiss the edit and redo the changes, then retry committing.


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