siyuan-note/siyuan · warning

Conf.language(239)

Error message

Conf.language(239)

What it means

RemoveBox uses a per-notebook lock (boxLock sync.Map). If the same boxID is already being removed (LoadOrStore returns loaded=true), it fails fast with localized message Conf.language(239) — the standard 'operation in progress / notebook is busy' user-facing message — instead of running a second concurrent removal. It is a concurrency guard, not a data error.

Solutions

  1. Wait for the first removal to finish; check /api/notebook/lsNotebooks to confirm the notebook is gone before retrying
  2. Serialize removal calls client-side: keep only one in-flight request per notebook ID
  3. If the lock appears permanently stuck, restart the kernel — boxLock is in-memory and cleared on restart
  4. Catch this error in the caller and treat it as 'already being removed' rather than retrying immediately
Defensive patterns

Strategy: try-catch

Validate before calling

// track in-flight removals client-side
const inFlight = new Set()
function canRemove(boxID) { return !inFlight.has(boxID) }

Try / catch

if err := removeNotebook(boxID); err != nil {
    if err.Error() == Conf.language(239) { // already locked / in progress
        // treat as benign: another removal is running; poll lsNotebooks instead of retrying
        return nil
    }
    return err
}

Prevention

When it happens

Trigger: Two concurrent calls to /api/notebook/removeNotebook for the same notebook ID, e.g. a double-clicked UI action, a plugin script racing a manual removal, or Unmount/notebookRemove/closeUserGuide firing while another removal of the same box is still in flight.

Common situations: Automation scripts retrying a slow removal without waiting for the first request to finish; frontend firing the remove request twice on unstable network with a retry wrapper; plugins listening to notebook events and reacting to the removal with the same removal call.

Related errors


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

Appendix: source

Thrown at kernel/model/mount.go:272

func collectBoxDeletedAttributeViewBlocks(boxID string) (ret map[string]map[string]struct{}, err error) {
	rootIDs := treenode.GetRootBlockIDsByBoxID(boxID)
	if 1 > len(rootIDs) {
		return map[string]map[string]struct{}{}, nil
	}
	boundAVIDs, err := sql.QueryBoundBlockAVIDsInBox(nil, rootIDs, boxID)
	if nil != err {
		return nil, err
	}
	return groupDeletedAttributeViewBlocks(boundAVIDs), nil
}

func RemoveBox(boxID string) (err error) {
	if !ast.IsNodeIDPattern(boxID) {
		return errors.New("invalid notebook ID")
	}
	if _, loaded := boxLock.LoadOrStore(boxID, true); loaded {
		err = errors.New(Conf.language(239))
		return
	}
	defer boxLock.Delete(boxID)

	if util.IsReservedFilename(boxID) {
		return fmt.Errorf("can not remove [%s] caused by it is a reserved file", boxID)
	}

	FlushTxQueue()
	sql.FlushQueue()
	// 索引和笔记本目录删除后无法再读取 custom-avs,需提前收集;实际删除成功后再清理绑定行。
	deletedAttrViewBlockIDs, err := collectBoxDeletedAttributeViewBlocks(boxID)
	if nil != err {
		return fmt.Errorf("query database-bound blocks in notebook [%s] failed: %w", boxID, err)
	}
	isUserGuide := IsUserGuide(boxID)
	localPath := filepath.Join(util.DataDir, boxID)
	if !filelock.IsExist(localPath) {

View on GitHub (pinned to 9f775e8a12)