{"record":{"id":"41a778f5f418a224","repo":"GitoxideLabs/gitoxide","slug":"history-worker-stopped-unexpectedly","errorCode":null,"errorMessage":"history worker stopped unexpectedly","messagePattern":"history worker stopped unexpectedly","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"gix-tix/src/lib.rs","lineNumber":1737,"sourceCode":"                fill_repository.retain = false;\n                fill_repository.retained = None;\n            }\n            if quit_on_finish\n                && quit_inputs.is_empty()\n                && matches!(app.state, State::Complete)\n                && lane_receiver.is_none()\n            {\n                return Ok(app.lane_time);\n            }\n            continue;\n        }\n        let mut events = 0;\n        while !history_finished && events < EVENT_BATCH_SIZE {\n            let message = match receiver.try_recv() {\n                Ok(message) => message,\n                Err(mpsc::TryRecvError::Empty) => break,\n                Err(mpsc::TryRecvError::Disconnected) => {\n                    anyhow::bail!(\"history worker stopped unexpectedly\")\n                }\n            };\n            events += 1;\n            dirty = true;\n            match message? {\n                Event::Decorations(value) => {\n                    app.set_worktree_head((!repository_is_bare).then(|| decoration_head(&value)).flatten(), true);\n                    decorations = value;\n                }\n                Event::Commits(rows) => app.extend_commits(rows),\n                Event::HiddenCommits(rows) => app.extend_hidden_commits(rows),\n                Event::VisibleComplete => {\n                    if let Some(rows) = app.start_lane_computation() {\n                        lane_receiver = Some(start_lane_worker(rows));\n                    }\n                }\n                Event::Complete(graph) => {\n                    history_finished = true;","sourceCodeStart":1719,"sourceCodeEnd":1755,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/lib.rs#L1719-L1755","documentation":"The history worker thread that feeds events over an mpsc channel has terminated before sending all expected events. The main loop detects a disconnected channel while expecting messages and aborts instead of silently producing incomplete history output. This guards against a crashed/panicked worker silently corrupting results.","triggerScenarios":"The background history worker thread panicked or returned early (e.g. an internal Err was dropped, thread failed to spawn work) so the sender was dropped while the main loop still expected Event messages via receiver.try_recv().","commonSituations":"Worker thread panics on malformed repository data; history computation cancelled abnormally; a bug in the worker causing early return before channel closure protocol completes.","solutions":["Check the worker thread for panics or early `?` returns that drop the sender without signalling history_finished.","Ensure the worker sends a completion/terminal message before dropping the sender.","Wrap the worker body so errors are forwarded through the channel (`message?` is already handled) instead of returning early.","Re-run the command; if reproducible, capture a backtrace (RUST_BACKTRACE=1) and report the worker panic."],"exampleFix":"// before\nlet handle = thread::spawn(move || {\n    compute_history(tx)?; // early return drops tx silently\n});\n// after\nlet handle = thread::spawn(move || {\n    let result = compute_history(&tx);\n    let _ = tx.send(Event::Done(result.is_ok()));\n    result\n});","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match result {\n    Err(err) if err.to_string().contains(\"history worker stopped unexpectedly\") => {\n        // restart the operation or report worker crash\n    }\n    other => other?,\n}","preventionTips":["Always send a terminal event before dropping the worker's sender.","Catch panics in worker threads and forward them over the channel.","Avoid early `?` returns in worker bodies that skip the completion signal."],"tags":["channels","worker-thread","rust","mpsc"],"backgroundTag":"worker-thread-crashed","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}