gitbutlerapp/gitbutler · error
Failed to join thread
Error message
Failed to join thread: {e:?} What it means
After spawning the worker thread that lists GitLab pipeline jobs for a reference, ci_checks_for_ref calls join(). If the thread panicked (rather than returning Err), join yields Err and this message wraps it, discarding the panic payload's readability. It indicates the CI check query crashed rather than failing gracefully.
Solutions
- Retry fetching CI checks (transient panic cause may be gone)
- Inspect the debug-formatted payload and fix the underlying panic in the checks code path
- Capture the join error payload in the message for diagnosis; consider running the async work on a shared runtime instead of a thread
Example fix
// before
.join().map_err(|e| anyhow::anyhow!("Failed to join thread: {e:?}"))?;
// after
.join().map_err(|e| anyhow::anyhow!("CI checks thread panicked: {e:?}").context("fetching gitlab checks"))??; Defensive patterns
Strategy: retry
Try / catch
match fetch_ci_checks() {
Err(e) if e.to_string().contains("Failed to join thread") => {
eprintln!("CI worker panicked: {e:#}"); retry_with_backoff()
}
other => other,
} Prevention
- Avoid unwraps on forge API response data in the checks path
- Retry transient CI fetches with backoff
- Log the join error payload ({e:?}) to capture the underlying panic
When it happens
Trigger: The GitLab checks worker thread panics while running list_pipeline_jobs_for_ref — e.g. an unwrap on API data, poisoned mutex on shared storage, or tokio runtime issue inside the thread.
Common situations: Unexpected GitLab API response shapes hitting unwrap/expect; concurrent access poisoning shared storage; panicking async runtime setup inside the thread.
Related errors
- Archive progress counter thread panicked
- Failed to create tokio runtime
- Failed to join thread
- thread panicked
- Update check thread panicked
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/40ce79f3132fb76f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-forge/src/ci.rs:119
let owner = owner.clone();
let repo = repo.clone();
let storage = storage.clone();
let reference = reference.to_string();
let reference_for_checks = reference.clone();
let checks = std::thread::spawn(move || {
tokio::runtime::Runtime::new()
.unwrap()
.block_on(but_github::checks::list_for_ref(
preferred_account.as_ref(),
&owner,
&repo,
&reference,
&storage,
))
})
.join()
.map_err(|e| anyhow::anyhow!("Failed to join thread: {e:?}"))?;
checks.map(|maybe_runs| {
maybe_runs.map(|runs| {
runs.into_iter()
.map(|check| {
let mut ci_check = CiCheck::from(check);
ci_check.reference = reference_for_checks.to_string();
ci_check
})
.collect()
})
})
}
ForgeName::GitLab => {
let preferred_account = preferred_forge_user
.as_ref()
.and_then(|user| user.gitlab().cloned());
// Clone owned data for threadView on GitHub (pinned to 58e5313667)