siyuan-note/siyuan · error

load created shorthand document

Error message

load created shorthand document [%s] failed: %w

What it means

As part of persistence verification, verifyShorthandDocPersisted clears the tree cache and reloads the document from disk via loadTreeByBlockTree. If that reload fails, the created shorthand document cannot be read back from the filesystem and the error "load created shorthand document [%s] failed: %w" wraps the underlying cause.

Solutions

  1. Inspect the wrapped cause (%w) to see whether it is I/O, permission, or parse failure and fix that first
  2. Check disk space and file permissions in the workspace data directory
  3. Retry after excluding the workspace from antivirus/backup tooling that may lock new files

Example fix

// before
persisted, err := loadTreeByBlockTree(bt)
// after
persisted, err := loadTreeByBlockTree(bt)
if err != nil {
    logging.LogErrorf("reload shorthand doc %s: %v", expectedID, err) // surface the wrapped cause
}
Defensive patterns

Strategy: try-catch

Validate before calling

const st = await api.getFileStats(dataDir)
if (st.freeBytes < 10 * 1024 * 1024) throw new Error('insufficient disk space for document creation')

Try / catch

try { await createShorthand(boxID, hPath, dom) } catch (e) { if (String(e).includes('load created shorthand document')) { logCause(e); checkDiskAndPermissions(); } throw e }

Prevention

When it happens

Trigger: loadTreeByBlockTree returns an error right after creation — unreadable/corrupt .sy file on disk, missing file despite a recorded block tree entry, disk I/O or permission problems, or parse failures on the freshly written XML.

Common situations: Full disk or antivirus interference preventing the .sy write; permission issues in the data directory; sync processes rewriting the file mid-verification.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/1d3ff8d94f8facf5. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/shortcuts.go:325

	if err = verifyShorthandDocPersisted(bt, retID); nil != err {
		return
	}
	box.setSortByConf(path.Dir(bt.Path), retID)

	FlushTxQueue()
	PushCreate(box, bt.Path, nil)
	return
}

func verifyShorthandDocPersisted(bt *treenode.BlockTree, expectedID string) (err error) {
	if nil == bt {
		return fmt.Errorf("get block tree by id [%s] failed after create", expectedID)
	}
	// 清除写入缓存,确保从文件系统重新读取并验证文档。
	cache.RemoveTreeDataInBox(expectedID, bt.BoxID)
	persisted, err := loadTreeByBlockTree(bt)
	if nil != err {
		return fmt.Errorf("load created shorthand document [%s] failed: %w", expectedID, err)
	}
	if nil == persisted || persisted.ID != expectedID {
		return fmt.Errorf("verify created shorthand document [%s] failed", expectedID)
	}
	return nil
}

var consumeShorthandsLock = sync.Mutex{}
var shorthandSaveBoxUnavailableNotified bool

func isShorthandSaveBoxAvailable(box *Box) bool {
	return nil != box && !box.Closed && !box.Encrypted && !IsUserGuide(box.ID)
}

func selectShorthandSaveBox(configuredID string, boxes []*Box) *Box {
	if "" != configuredID {
		for _, box := range boxes {
			if nil != box && box.ID == configuredID && isShorthandSaveBoxAvailable(box) {

View on GitHub (pinned to 9f775e8a12)