siyuan-note/siyuan · warning · ErrIndexing
indexing
Error message
indexing
What it means
Sentinel error ErrIndexing declared at tree.go:206 ('indexing'). Returned when a block/tree lookup fails because the kernel is actively indexing (task.ContainIndexTask() is true) OR the searchTreeLimiter rate limiter prevents a filesystem fallback reindex (indexTreeInFilesystem at tree.go:332). It signals a TRANSIENT state: the data may become available once indexing completes.
Source
Thrown at kernel/model/tree.go:206
logging.LogErrorf("decrypt tree [path=%s] failed: %s", localPath, 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 251596fc0d)
Solutions
- Treat ErrIndexing as transient: retry the operation after indexing completes (poll boot progress or use the indexing-complete WebSocket event).
- Use errors.Is(err, model.ErrIndexing) to return a 503/retry-after style response to API clients.
- Avoid flooding lookups during reindex; the rate limiter (3s) intentionally throttles filesystem reindex attempts.
- If stuck, check task.ContainIndexTask() status and kernel boot progress (util.IsBooted()).
Example fix
// before — treat all errors as fatal
tree, err := LoadTreeByBlockID(id)
if err != nil { return fatal(err) }
// after — retry on transient indexing error
tree, err := LoadTreeByBlockID(id)
if errors.Is(err, model.ErrIndexing) {
return retryLater()
} Defensive patterns
Strategy: retry
Validate before calling
func isStillIndexing() bool {
return task.ContainIndexTask() || !util.IsBooted()
} Try / catch
for attempt := 0; attempt < maxAttempts; attempt++ {
tree, err := model.LoadTreeByBlockID(id)
if err == nil { return tree, nil }
if !errors.Is(err, model.ErrIndexing) { return nil, err }
// wait for indexing progress via WS event, then retry
waitForIndexProgress()
} Prevention
- Treat ErrIndexing as transient — retry after indexing completes, do not surface as a hard failure.
- Subscribe to the boot-progress / indexing-complete WebSocket event to know when to retry.
- Avoid hammering lookups during reindex; the 3s rate limiter will throttle filesystem reindex attempts.
When it happens
Trigger: During boot/notebook reindex, task.ContainIndexTask() returns true so LoadTreeByBlockIDWithReindexInBox/loadTreeByBlockIDInBox0 return ErrIndexing instead of attempting filesystem reindex; alternatively, the rate limiter (1 per 3s) blocks a fallback reindex attempt. API handlers in block.go check errors.Is(err, model.ErrIndexing) to return a 'try again later' response.
Common situations: Opening/operating on a doc immediately after kernel boot while notebooks are still indexing; a large notebook reindex in progress; rapid repeated lookups triggering the rate limiter; importing a large dataset then immediately querying.
Related errors
- refresh OAuth credentials: %w
- Related operations are being processed, please try again lat
- Related operations are being processed, please try again lat
- notebook unindexed
- read custom emoji response failed: %w
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/8a13ba8893cd7cfe.
Report an issue: GitHub.