siyuan-note/siyuan · warning

ErrIndexing

ErrIndexing

Error message

indexing

What it means

ErrIndexing is the sentinel returned when the requested data is not yet available because the block index is being (re)built — the operation must be retried after indexing finishes. Handlers translate it to code 3 and the localized 'indexing' message (Conf.Language(56)) so the frontend shows a temporary state instead of an error.

Solutions

  1. Wait for indexing to finish and retry the request — handlers return code 3 with Conf.Language(56) for this purpose
  2. Poll /api/query/sql or block info until the block appears, with exponential backoff
  3. Avoid issuing block queries immediately after boot or after triggering reindex; listen for index-complete push messages
  4. Persist model.ErrIndexing semantics in your client as 'temporarily unavailable, retry' rather than a hard failure

Example fix

// before
root, err := model.GetBlock(block.RootID, tree)
if err != nil { return err }

// after
if errors.Is(err, model.ErrIndexing) {
    return apicontract.FailureWithText[apicontract.BlockInfoData](3, ret.Msg, model.Conf.Language(56))
}
Defensive patterns

Strategy: retry

Validate before calling

// TypeScript: wait for indexing before heavy queries
await new Promise(r => setTimeout(r, 1000)); // back off after boot/reindex
const info = await fetchPost('/api/block/getDocInfo', { id });
if (info.code === 3) { /* still indexing: retry with backoff */ }

Type guard

function isIndexing(msg: string | null | undefined): boolean {
  return msg === 'indexing';
}

Try / catch

// Go
if errors.Is(err, model.ErrIndexing) {
    return apicontract.FailureWithText[apicontract.BlockInfoData](3, ret.Msg, model.Conf.Language(56))
}

Prevention

When it happens

Trigger: GetDocInfoInBox, LoadTreeByBlockIDWithReindexInBox, loadTreeByBlockIDInBox0, ReindexMissingNormalBlock and setGetBlockInfoError paths hit a block that exists in the doc but is not yet in the database during a reindex (kernel/api/block.go:371, :712); queries issued right after boot or after /api/filetree/refresh/reindex.

Common situations: Opening a large workspace and querying blocks immediately; a plugin/integration running right after startup before index queues drain; a doc created/edited while assets/FTS indexing is still in flight; triggering reindex then fetching docs concurrently.

Related errors


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

Appendix: 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 9f775e8a12)