siyuan-note/siyuan · warning

ErrIndexing

ErrIndexing

Error message

indexing

What it means

ErrIndexing is the sentinel error meaning the requested tree/block is currently being re-indexed and is not yet available. Functions like getDocInfo, getBlockInfo, and LoadTreeByBlockIDWithReindex return it to tell API handlers the operation is transient; handlers respond with a localized 'indexing' message (Language(56)) or a special code (3) so clients retry.

Source

Thrown at kernel/model/tree.go:214

	}

	if err = treenode.CheckSpecJSON(data); nil != err {
		return
	}
	ret, err = dataparser.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
	if err != nil {
		logging.LogErrorf("parse json to tree [%s] failed: %s", localPath, err)
		return
	}
	return
}

var (
	ErrBoxNotFound   = errors.New("notebook not found")
	ErrBoxClosed     = errors.New("notebook closed")
	ErrBlockNotFound = errors.New("block not found")
	ErrTreeNotFound  = errors.New("tree not found")
	ErrIndexing      = errors.New("indexing")
	ErrBoxUnindexed  = errors.New("notebook unindexed")
	ErrInvalidID     = errors.New("invalid id")
)

func LoadTreeByBlockIDWithReindex(id string) (ret *parse.Tree, err error) {
	return LoadTreeByBlockIDWithReindexInBox(id, "")
}

// LoadTreeByBlockIDWithReindexInBox 与 LoadTreeByBlockIDWithReindex 一致,但按 boxID 路由 blocktree 查询。
func LoadTreeByBlockIDWithReindexInBox(id, boxID string) (ret *parse.Tree, err error) {
	if "" == id {
		logging.LogWarnf("block id is empty")
		return nil, ErrTreeNotFound
	}

	bt := treenode.GetBlockTreeInBox(id, boxID)
	if nil == bt && "" == boxID {
		// boxID 未知时(如通用打开入口),遍历所有已打开的加密笔记本查找

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Wait briefly and retry the same request until indexing finishes (the API returns code 3 to signal retry)
  2. Wait for the index-queue idle / task-complete WebSocket push before running scripts against fresh workspaces
  3. Do not treat this as fatal — check errors.Is(err, model.ErrIndexing) and return a localized 'indexing in progress' message instead of an error

Example fix

// before
ret.Msg = err.Error()
// after
if errors.Is(err, model.ErrIndexing) {
    ret.Code = 3
    ret.Msg = model.Conf.Language(56)
}
Defensive patterns

Strategy: retry

Validate before calling

for i := 0; i < 10; i++ {
    info, err := getBlockInfo(id)
    if err == nil || !errors.Is(err, model.ErrIndexing) { break }
    time.Sleep(500 * time.Millisecond)
}

Try / catch

if errors.Is(err, model.ErrIndexing) {
    ret.Code = 3
    ret.Msg = model.Conf.Language(56) // client retries
    return
}

Prevention

When it happens

Trigger: Requesting block/doc info while a notebook's index queue is actively rebuilding (freshly opened workspace, import, or reindex operation); LoadTreeByBlockIDWithReindex detecting an index miss and kicking off reindexing.

Common situations: Frontend loads immediately after app start or after a large import before indexing finishes; scripts/automations racing with a Rebuild Index operation; a newly created notebook queried before its first index completes.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/7c934b65c7c5e43a. Report an issue: GitHub.