toeverything/AFFiNE · error · Error
Failed to create doc
Error message
Failed to create doc
What it means
createDoc throws when store.createDoc succeeds but getBlockSuiteDoc returns null for the fresh id, meaning the newly created doc could not be materialized in the BlockSuite store — an internal consistency failure.
Source
Thrown at packages/frontend/core/src/modules/doc/services/docs.ts:153
const doc = docScope.get(DocService).doc;
doc.scope.emitEvent(DocInitialized, doc);
const { obj, release } = this.pool.put(docId, doc);
return { doc: obj, release };
}
createDoc(options: DocCreateOptions = {}) {
for (const middleware of this.docCreateMiddlewares) {
options = middleware.beforeCreate
? middleware.beforeCreate(options)
: options;
}
const id = this.store.createDoc(options.id);
const docStore = this.store.getBlockSuiteDoc(id);
if (!docStore) {
throw new Error('Failed to create doc');
}
if (options.skipInit !== true) {
initDocFromProps(docStore, options.docProps, options);
}
const docRecord = this.list.doc$(id).value;
if (!docRecord) {
throw new Unreachable();
}
if (options.primaryMode) {
docRecord.setPrimaryMode(options.primaryMode);
}
if (options.isTemplate) {
docRecord.setProperty('isTemplate', true);
}
for (const middleware of this.docCreateMiddlewares) {
middleware.afterCreate?.(docRecord, options);
}
docRecord.setCreatedAt(Date.now());View on GitHub (pinned to b4c8548c09)
Solutions
- Retry doc creation; ensure the workspace is available.
- Check storage quota and permissions.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown by createDoc when store.createDoc succeeded but store.getBlockSuiteDoc for the new id returns null, so the newly created doc cannot be retrieved for initialization.
Common situations: Doc creation fails right after the record is made because the doc store cannot be fetched, usually a transient storage engine issue. Retry creating the doc; if it persists, check workspace storage health.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/0d44ab615336eaf1.
Report an issue: GitHub.