BigPizzaV3/CodexPlusPlus · error

session index cleanup task failed

Error message

session index cleanup task failed: {error}

What it means

apply_session_index_cleanup runs codex_plus_data::apply_session_index_cleanup(None, &snapshot_sha256, &thread_ids) on a blocking thread via tauri::async_runtime::spawn_blocking. A JoinError from awaiting the handle (task panicked or was cancelled) is mapped into this error; it is the outer failure, distinct from an inner cleanup Result error which is handled separately in the match.

Solutions

  1. Read the wrapped JoinError message to locate the panic in apply_session_index_cleanup
  2. Verify the index directory is writable and has free space (backup write failures are a common panic trigger)
  3. Check that snapshot_sha256 matches the preview's snapshot; stale snapshots can lead downstream into bad state
  4. Convert panic paths (unwrap/expect) in the cleanup data layer into returned errors, then retry the cleanup
Defensive patterns

Strategy: try-catch

Validate before calling

// 执行前确认 snapshot 仍与当前索引匹配,避免过期快照导致清理路径异常
if !snapshot_matches_current_index(&snapshot_sha256) {
    return Err(anyhow::anyhow!("索引快照已过期,请重新执行预览"));
}

Try / catch

match tauri::async_runtime::spawn_blocking(move || {
    codex_plus_data::apply_session_index_cleanup(None, &snapshot_sha256, &thread_ids)
}).await {
    Ok(Ok(cleanup)) => { /* 汇报清理结果 */ }
    Ok(Err(data_err)) => eprintln!("cleanup failed: {data_err}(原索引有备份,可恢复)"),
    Err(join_err) => eprintln!("cleanup task panicked or was cancelled: {join_err}"),
}

Prevention

When it happens

Trigger: The spawn_blocking closure for apply_session_index_cleanup panicked (e.g. while pruning/rewriting the index or writing the backup) or the JoinHandle resolved to Err(JoinError) due to runtime cancellation.

Common situations: Panic while writing the index backup or rewriting session index files (disk full, permission denied on an unwrap path), corrupted snapshot_sha256/thread_ids payloads causing panics in the cleanup logic, or app exit cancelling the task mid-run.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/99b72f0a9b706459. Report an issue: GitHub.

Appendix: source

Thrown at apps/codex-plus-manager/src-tauri/src/commands.rs:3261

            json!({
                "snapshotSha256": preview.snapshot_sha256,
                "candidates": preview.candidates,
            }),
        ),
        Err(error) => failed(&format!("预览失效任务索引失败:{error}"), json!({})),
    }
}

#[tauri::command]
pub async fn apply_session_index_cleanup(
    snapshot_sha256: String,
    thread_ids: Vec<String>,
) -> CommandResult<Value> {
    let result = tauri::async_runtime::spawn_blocking(move || {
        codex_plus_data::apply_session_index_cleanup(None, &snapshot_sha256, &thread_ids)
    })
    .await
    .map_err(|error| anyhow::anyhow!("session index cleanup task failed: {error}"));
    match result {
        Ok(Ok(cleanup)) => ok(
            &format!(
                "已清理 {} 条失效任务索引;原索引已完整备份。",
                cleanup.pruned_entries
            ),
            json!({
                "prunedEntries": cleanup.pruned_entries,
                "backupDir": cleanup.backup_dir,
            }),
        ),
        Ok(Err(error)) => {
            let backup_hint = error
                .backup_dir
                .as_ref()
                .map(|path| format!(" 备份目录:{}。", path.to_string_lossy()))
                .unwrap_or_default();
            failed(

View on GitHub (pinned to b1ed92e5e4)