gitbutlerapp/gitbutler · error

diffing-thread crashed

Error message

diffing-thread crashed

What it means

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.

Solutions

  1. Retry the operation - if the worker panicked transiently (e.g. OOM), re-invoking the listing usually re-spawns a fresh thread.
  2. Check application logs for a panic message from the diffing thread to identify the underlying cause.
  3. If it reproduces consistently, isolate the branch(es) whose diff triggers the crash and inspect their tree contents (corrupt/unusual objects).
  4. Report the panic to GitButler with the repo characteristics; the worker should ideally be joined and its panic captured instead of failing silently.

Example fix

// before
if start.send((change_rx, res_tx)).is_err() {
    bail!("diffing-thread crashed");
};
// after
if start.send((change_rx, res_tx)).is_err() {
    // recover: respawn the diffing worker and retry once
    let start = spawn_diff_worker(repo)?; // helper that joins the dead thread and respawns
    start.send((change_rx, res_tx)).context("diffing-thread crashed")?;
}
Defensive patterns

Strategy: retry

Try / catch

match get_branch_listing_details(...) {
    Err(e) if e.to_string().contains("diffing-thread crashed") => retry_with_backoff(1)?,
    other => other?,
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/6caa1d83b5725fd4. Report an issue: GitHub.

Appendix: source

Thrown at crates/gitbutler-branch-actions/src/branch.rs:843

                    }
                    Ok(())
                }
            })?;

        for branch in branches {
            let Some((base, authors, num_commits)) = merge_rx.recv()? else {
                continue;
            };

            let branch_head = branch.head;
            let base_commit = repo.find_object(base)?.try_into_commit()?;
            let base_tree = base_commit.tree()?;
            let head_tree = repo.find_object(branch_head)?.peel_to_tree()?;

            let ((change_tx, change_rx), (res_tx, rex_rx)) =
                (std::sync::mpsc::channel(), std::sync::mpsc::channel());
            if start.send((change_rx, res_tx)).is_err() {
                bail!("diffing-thread crashed");
            };
            base_tree
                .changes()?
                .options(|opts| {
                    opts.track_rewrites(None);
                })
                // NOTE: `stats(head_tree)` is also possible, but we have a separate thread for that.
                .for_each_to_obtain_tree(&head_tree, move |change| -> anyhow::Result<Action> {
                    change_tx.send(change.detach()).ok();
                    Ok(std::ops::ControlFlow::Continue(()))
                })?;
            let (number_of_files, lines_added, lines_removed) = rex_rx.recv()?;

            let branch_data = BranchListingDetails {
                name: branch.name,
                lines_added,
                lines_removed,
                number_of_files,

View on GitHub (pinned to 58e5313667)