BigPizzaV3/CodexPlusPlus · error

export markdown task failed

Error message

export markdown task failed: {error}

What it means

This error wraps a JoinError from tokio::task::spawn_blocking in `export_markdown` (apps/codex-plus-launcher/src/main.rs:683). The blocking task calling codex_plus_data::export_markdown_from_paths never returned a value because it panicked or was cancelled. It is not a markdown-export logic error itself — the inner export errors propagate through the `?` on the JoinHandle result separately.

Solutions

  1. Check JoinError::is_panic and log the panic payload to find the bug in export_markdown_from_paths
  2. Harden export_markdown_from_paths to return Result instead of panicking on missing/corrupt dbs
  3. Ensure callers await the future to completion rather than dropping it
  4. If seen at shutdown, flush/wait pending exports before process exit

Example fix

// before
.map_err(|error| anyhow::anyhow!("export markdown task failed: {error}"))
// after
.map_err(|error| if error.is_panic() {
    anyhow::anyhow!("export markdown task panicked: {error}")
} else {
    anyhow::anyhow!("export markdown task cancelled: {error}")
})
Defensive patterns

Strategy: try-catch

Validate before calling

// verify session ref and db paths exist before exporting
if db_paths.is_empty() { return Err(anyhow::anyhow!("no candidate db paths")); }

Type guard

fn join_error_is_panic(err: &tokio::task::JoinError) -> bool { err.is_panic() }

Try / catch

match tokio::task::spawn_blocking(move || export_markdown_from_paths(paths, &session)).await {
    Ok(Ok(res)) => res,
    Ok(Err(e)) => eprintln!("export failed: {e}"),
    Err(je) => eprintln!("export task panicked/cancelled: {je}"),
}

Prevention

When it happens

Trigger: Calling `export_markdown(session)` when the spawned closure panics (bad session ref handling inside export_markdown_from_paths), when the caller future is dropped, or when the tokio runtime shuts down before the blocking thread finishes.

Common situations: Exporting a session whose db paths point at a file being deleted concurrently; app exit during a large export; panic on unwrap inside the export code.

Related errors


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

Appendix: source

Thrown at apps/codex-plus-launcher/src/main.rs:683

        })
        .await
        .map_err(|error| anyhow::anyhow!("delete task failed: {error}"))
    }

    async fn undo(&self, undo_token: String) -> anyhow::Result<DeleteResult> {
        let adapter = self.storage_adapter();
        tokio::task::spawn_blocking(move || adapter.undo(&undo_token))
            .await
            .map_err(|error| anyhow::anyhow!("undo task failed: {error}"))
    }

    async fn export_markdown(&self, session: SessionRef) -> anyhow::Result<ExportResult> {
        let db_paths = self.candidate_db_paths();
        tokio::task::spawn_blocking(move || {
            codex_plus_data::export_markdown_from_paths(db_paths, &session)
        })
        .await
        .map_err(|error| anyhow::anyhow!("export markdown task failed: {error}"))
    }

    async fn thread_usage_history(&self, session: SessionRef) -> anyhow::Result<Value> {
        let adapter = self.storage_adapter();
        tokio::task::spawn_blocking(move || adapter.codex_thread_usage_history(&session))
            .await
            .map_err(|error| anyhow::anyhow!("thread usage history task failed: {error}"))
    }

    async fn find_archived_thread_by_title(
        &self,
        title: String,
    ) -> anyhow::Result<Option<SessionRef>> {
        let adapter = self.storage_adapter();
        tokio::task::spawn_blocking(move || adapter.find_archived_thread_by_title(&title))
            .await
            .map_err(|error| anyhow::anyhow!("archived lookup task failed: {error}"))
    }

View on GitHub (pinned to b1ed92e5e4)