toeverything/AFFiNE · error · Error
Failed to create doc for editing
Error message
Failed to create doc for editing
What it means
startEdit uses snapshotHelper.createStore(snapshot) to materialize a temp doc for comment editing; a null return means the store could not be created from the snapshot, so editing cannot start and this Error is thrown.
Source
Thrown at packages/frontend/core/src/modules/comment/entities/doc-comment.ts:182
}
dismissDraftReply(): void {
this.pendingReply$.setValue(null);
}
/**
* Start editing an existing comment or reply.
* This will dismiss any previous editing draft so that only one can exist.
*/
async startEdit(
id: CommentId,
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,View on GitHub (pinned to b4c8548c09)
Solutions
- Retry; ensure the workspace and doc service are initialized before editing comments.
- Check storage/permissions for doc creation.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown when startEdit in the comment entity cannot materialize a BlockSuite store from the comment snapshot, i.e. snapshotHelper.createStore returns null. Indicates a corrupted or incompatible comment content snapshot when beginning to edit a comment or reply.
Common situations: A user tries to edit an existing comment or reply whose stored snapshot is invalid or from an incompatible schema. Retry after reloading the doc; if persistent, the comment data may be corrupted and need re-creation.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/b0bcac4ed9848f73.
Report an issue: GitHub.