{"record":{"id":"2ef1af4eea945f12","repo":"BigPizzaV3/CodexPlusPlus","slug":"thread-usage-history-task-failed-error","errorCode":null,"errorMessage":"thread usage history task failed: {error}","messagePattern":"thread usage history task failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/codex-plus-launcher/src/main.rs","lineNumber":690,"sourceCode":"        tokio::task::spawn_blocking(move || adapter.undo(&undo_token))\n            .await\n            .map_err(|error| anyhow::anyhow!(\"undo task failed: {error}\"))\n    }\n\n    async fn export_markdown(&self, session: SessionRef) -> anyhow::Result<ExportResult> {\n        let db_paths = self.candidate_db_paths();\n        tokio::task::spawn_blocking(move || {\n            codex_plus_data::export_markdown_from_paths(db_paths, &session)\n        })\n        .await\n        .map_err(|error| anyhow::anyhow!(\"export markdown task failed: {error}\"))\n    }\n\n    async fn thread_usage_history(&self, session: SessionRef) -> anyhow::Result<Value> {\n        let adapter = self.storage_adapter();\n        tokio::task::spawn_blocking(move || adapter.codex_thread_usage_history(&session))\n            .await\n            .map_err(|error| anyhow::anyhow!(\"thread usage history task failed: {error}\"))\n    }\n\n    async fn find_archived_thread_by_title(\n        &self,\n        title: String,\n    ) -> anyhow::Result<Option<SessionRef>> {\n        let adapter = self.storage_adapter();\n        tokio::task::spawn_blocking(move || adapter.find_archived_thread_by_title(&title))\n            .await\n            .map_err(|error| anyhow::anyhow!(\"archived lookup task failed: {error}\"))\n    }\n\n    async fn recover_remote_control_session(&self, thread_id: String) -> anyhow::Result<Value> {\n        let settings = codex_plus_core::settings::SettingsStore::default()\n            .load()\n            .unwrap_or_default();\n        let profile = settings.active_relay_profile();\n        if !settings.relay_profiles_enabled","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/apps/codex-plus-launcher/src/main.rs#L672-L708","documentation":"This error wraps a JoinError from tokio::task::spawn_blocking in `thread_usage_history` (apps/codex-plus-launcher/src/main.rs:690). The blocking task running adapter.codex_thread_usage_history never completed normally — it panicked or was cancelled by the runtime. Database/query errors from the adapter are returned through the inner Result, not this message.","triggerScenarios":"Calling `thread_usage_history(session)` when the blocking closure panics (e.g. unwrap on malformed usage JSON), when the future is cancelled, or during runtime shutdown.","commonSituations":"Querying usage history for a session with corrupted usage records; aborting the request when the UI navigates away; process teardown mid-query.","solutions":["Inspect the JoinError for a panic payload pointing at codex_thread_usage_history","Replace panicking unwraps in the adapter with proper error returns","Keep the future alive until it resolves; don't abort on UI navigation","At shutdown, wait for pending blocking tasks before dropping the runtime"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn join_error_is_panic(err: &tokio::task::JoinError) -> bool { err.is_panic() }","tryCatchPattern":"Err(tokio::task::JoinError) with is_panic() => log into_panic() payload; otherwise treat as cancellation and optionally retry once","preventionTips":["Don't cancel usage-history queries when UI navigates away","Make codex_thread_usage_history panic-free on corrupt records","Drain blocking tasks at shutdown"],"tags":["rust","tokio","join-error","async","usage-history"],"backgroundTag":"thread-interrupted","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}