{"record":{"id":"d91b03646af817e9","repo":"gitbutlerapp/gitbutler","slug":"update-check-thread-panicked","errorCode":null,"errorMessage":"Update check thread panicked","messagePattern":"Update check thread panicked","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-update/src/check.rs","lineNumber":138,"sourceCode":"            let response = client\n                .post(url)\n                .json(&request_body)\n                .send()\n                .await\n                .map_err(|e| anyhow::anyhow!(\"Request failed: {e}\"))?\n                .error_for_status()\n                .map_err(|e| anyhow::anyhow!(\"Server returned error: {e}\"))?;\n\n            let update_info = response\n                .json::<CheckUpdateStatus>()\n                .await\n                .map_err(|e| anyhow::anyhow!(\"Failed to parse response: {e}\"))?;\n\n            Ok(update_info)\n        })\n    })\n    .join()\n    .map_err(|_| anyhow::anyhow!(\"Update check thread panicked\"))?;\n\n    // Save to cache (convert to but_db types)\n    if let Ok(status) = &result {\n        let now = chrono::Utc::now();\n\n        // Get existing cache to preserve suppression\n        let existing = trans.update_check().get();\n        let (suppressed_at, suppress_duration_hours) = existing\n            .and_then(|cached| cached.suppressed_at.zip(cached.suppress_duration_hours))\n            .and_then(|(suppressed_at, duration_hours)| {\n                let suppress_until = suppressed_at + chrono::Duration::hours(duration_hours as i64);\n                if now > suppress_until {\n                    None\n                } else {\n                    Some((suppressed_at, duration_hours))\n                }\n            })\n            .unzip();","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-update/src/check.rs#L120-L156","documentation":"Thrown when the thread spawned to run the update check panicked instead of returning a Result. Thread::join returns Err on panic, and since the panic payload is discarded, this message deliberately loses the original panic cause. The library treats a panicked worker thread as a failed update check.","triggerScenarios":"check_status/check_status_with_url when the closure inside std::thread::spawn panics — e.g. an unexpected panic inside the tokio runtime, reqwest, or TLS backend during block_on — and .join() returns Err(_).","commonSituations":"A bug or abort in a native TLS/runtime dependency triggering a panic; stack exhaustion inside the spawned thread; panics escalated by panic=abort-style settings in embedded environments.","solutions":["Retry the update check; a single panicking thread is often transient.","Reproduce with panic logging enabled (set a panic hook) to find the real panic message, since this wrapper discards it.","Update the crate/dependencies — a panic in reqwest/tokio/backends is usually a library bug.","If reproducible, file a bug including the underlying panic backtrace obtained via RUST_BACKTRACE=1 and a panic hook."],"exampleFix":"// before\n.join()\n.map_err(|_| anyhow::anyhow!(\"Update check thread panicked\"))?;\n// after: preserve the panic cause\n.join()\n.map_err(|payload| {\n    let msg = payload.downcast_ref::<String>().cloned()\n        .or_else(|| payload.downcast_ref::<&str>().map(|s| s.to_string()))\n        .unwrap_or_else(|| \"unknown panic\".into());\n    anyhow::anyhow!(\"Update check thread panicked: {msg}\")\n})?;","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match but_update::check_status(app, &settings, &mut cache) {\n    Err(e) if e.to_string().contains(\"thread panicked\") => {\n        // transient internal panic: install a panic hook for diagnosis and retry once\n        log::warn!(\"update check worker panicked\");\n        but_update::check_status(app, &settings, &mut cache)\n    }\n    other => other?,\n}","preventionTips":["Install a panic hook (std::panic::set_hook) so panics inside worker threads are logged with backtraces.","Run with RUST_BACKTRACE=1 when reproducing to capture the underlying panic.","Keep reqwest/tokio/TLS dependencies updated; panics here are usually library bugs.","Avoid deep recursion or huge payloads on the update-check thread."],"tags":["panic","threading","updater"],"backgroundTag":"thread-interrupted","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}