{"record":{"id":"6caa1d83b5725fd4","repo":"gitbutlerapp/gitbutler","slug":"diffing-thread-crashed","errorCode":null,"errorMessage":"diffing-thread crashed","messagePattern":"diffing-thread crashed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-branch-actions/src/branch.rs","lineNumber":843,"sourceCode":"                    }\n                    Ok(())\n                }\n            })?;\n\n        for branch in branches {\n            let Some((base, authors, num_commits)) = merge_rx.recv()? else {\n                continue;\n            };\n\n            let branch_head = branch.head;\n            let base_commit = repo.find_object(base)?.try_into_commit()?;\n            let base_tree = base_commit.tree()?;\n            let head_tree = repo.find_object(branch_head)?.peel_to_tree()?;\n\n            let ((change_tx, change_rx), (res_tx, rex_rx)) =\n                (std::sync::mpsc::channel(), std::sync::mpsc::channel());\n            if start.send((change_rx, res_tx)).is_err() {\n                bail!(\"diffing-thread crashed\");\n            };\n            base_tree\n                .changes()?\n                .options(|opts| {\n                    opts.track_rewrites(None);\n                })\n                // NOTE: `stats(head_tree)` is also possible, but we have a separate thread for that.\n                .for_each_to_obtain_tree(&head_tree, move |change| -> anyhow::Result<Action> {\n                    change_tx.send(change.detach()).ok();\n                    Ok(std::ops::ControlFlow::Continue(()))\n                })?;\n            let (number_of_files, lines_added, lines_removed) = rex_rx.recv()?;\n\n            let branch_data = BranchListingDetails {\n                name: branch.name,\n                lines_added,\n                lines_removed,\n                number_of_files,","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-branch-actions/src/branch.rs#L825-L861","documentation":"get_branch_listing_details computes per-branch diff statistics on a dedicated diffing worker thread, feeding it changes over std::sync::mpsc channels. This error is raised when sending the (change_rx, res_tx) channel pair to the worker via `start.send(...)` fails, which only happens if the receiving thread has already exited (panicked or returned). It signals that the internal diff worker is gone, so branch details cannot be computed.","triggerScenarios":"Calling get_branch_listing_details (branch listing enrichment in gitbutler-branch-actions) when the spawned diffing thread has terminated prematurely - e.g. it panicked inside its diff-stat closure, or exited its loop early because a previous `merge_tx.send(...)` failed (receiver dropped mid-iteration).","commonSituations":"Large or exotic repositories causing the diff worker to panic; an earlier branch in the listing produced a receiver-side channel error causing the worker loop to `break`, so subsequent branches hit the dead sender; resource exhaustion (OOM) killing the worker thread.","solutions":["Retry the operation - if the worker panicked transiently (e.g. OOM), re-invoking the listing usually re-spawns a fresh thread.","Check application logs for a panic message from the diffing thread to identify the underlying cause.","If it reproduces consistently, isolate the branch(es) whose diff triggers the crash and inspect their tree contents (corrupt/unusual objects).","Report the panic to GitButler with the repo characteristics; the worker should ideally be joined and its panic captured instead of failing silently."],"exampleFix":"// before\nif start.send((change_rx, res_tx)).is_err() {\n    bail!(\"diffing-thread crashed\");\n};\n// after\nif start.send((change_rx, res_tx)).is_err() {\n    // recover: respawn the diffing worker and retry once\n    let start = spawn_diff_worker(repo)?; // helper that joins the dead thread and respawns\n    start.send((change_rx, res_tx)).context(\"diffing-thread crashed\")?;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match get_branch_listing_details(...) {\n    Err(e) if e.to_string().contains(\"diffing-thread crashed\") => retry_with_backoff(1)?,\n    other => other?,\n}","preventionTips":["Retry listing operations once before surfacing errors to the user","Capture worker panics (catch_unwind) in custom thread code so failures are diagnosable","Keep diff worker lifetimes scoped to the operation so dead senders are detected early"],"tags":["concurrency","thread-panic","channel-disconnected","git-diff"],"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"}