siyuan-note/siyuan · warning

Conf.Language(239)

Error message

Conf.Language(239)

What it means

RollbackNotebookHistory uses a per-box mutex (boxLock with LoadOrStore) to prevent concurrent rollbacks of the same notebook. If a rollback for that boxID is already in flight, the second call immediately fails with the localized message Conf.Language(239), which tells the user the notebook history is currently being rolled back.

Solutions

  1. Wait for the in-flight rollback to finish and retry once
  2. Serialize notebook rollback calls in the caller (single-flight / queue per boxID)
  3. Disable the rollback button/entry while a rollback request is pending in the UI

Example fix

// before
Promise.all([rollbackNotebookHistory(p), rollbackNotebookHistory(p)])
// after
await rollbackNotebookHistory(p); // await before issuing again
Defensive patterns

Strategy: retry

Try / catch

try { await rollbackNotebookHistory(p); } catch (e) { if (isBusyNotebookMessage(e)) { await sleep(1000); await rollbackNotebookHistory(p); } else { throw e; } }

Prevention

When it happens

Trigger: Invoking RollbackNotebookHistory twice concurrently for the same notebook — e.g. double-clicking the rollback button, parallel API calls, or a script racing the UI.

Common situations: Automated scripts issuing overlapping rollback requests; slow rollback (large notebook) causing users to retry; multiple clients connected to the same workspace.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/history.go:653

	encrypted, err := isEncryptedHistoryBoxDir(filepath.Join(util.HistoryDir, parts[0], boxID))
	if err != nil {
		logging.LogErrorf("inspect encrypted history path [%s] failed: %s", absPath, err)
		return true
	}
	return encrypted
}

func RollbackNotebookHistory(historyPath string) (err error) {
	historyPath, err = validateHistoryPath(historyPath)
	if err != nil {
		return
	}
	boxID, err := validateNotebookHistoryPath(historyPath)
	if err != nil {
		return
	}
	if _, loaded := boxLock.LoadOrStore(boxID, true); loaded {
		return errors.New(Conf.Language(239))
	}
	defer boxLock.Delete(boxID)

	from := historyPath
	to := filepath.Join(util.DataDir, boxID)
	if filelock.IsExist(to) {
		return errors.New(Conf.Language(371))
	}

	if err = filelock.CopyNewtimes(from, to); err != nil {
		logging.LogErrorf("copy file [%s] to [%s] failed: %s", from, to, err)
		return
	}

	IncSync()
	ReloadFiletree()
	util.PushMsg(Conf.Language(372), 3000)
	return nil

View on GitHub (pinned to 9f775e8a12)