{"record":{"id":"f8880b4022b97d56","repo":"gitbutlerapp/gitbutler","slug":"failed-to-create-a-runtime-for-the-settled-review-sweep-e","errorCode":null,"errorMessage":"Failed to create a runtime for the settled-review sweep: {e}","messagePattern":"Failed to create a runtime for the settled-review sweep: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-forge/src/review.rs","lineNumber":671,"sourceCode":"    forge_repo_info: &crate::forge::ForgeRepoInfo,\n    storage: &but_forge_storage::Controller,\n) -> Result<Vec<ForgeReview>> {\n    let crate::forge::ForgeRepoInfo {\n        forge, owner, repo, ..\n    } = forge_repo_info;\n    let reviews = match forge {\n        ForgeName::GitHub => {\n            let preferred_account = preferred_forge_user\n                .as_ref()\n                .and_then(|user| user.github().cloned());\n            let owner = owner.clone();\n            let repo = repo.clone();\n            let storage = storage.clone();\n\n            let pulls = std::thread::spawn(move || {\n                tokio::runtime::Runtime::new()\n                    .map_err(|e| {\n                        anyhow::anyhow!(\n                            \"Failed to create a runtime for the settled-review sweep: {e}\"\n                        )\n                    })?\n                    .block_on(but_github::pr::list_recently_closed(\n                        preferred_account.as_ref(),\n                        &owner,\n                        &repo,\n                        &storage,\n                    ))\n            })\n            .join()\n            .map_err(|e| anyhow::anyhow!(\"Failed to join thread: {e:?}\"))??;\n\n            pulls.into_iter().map(ForgeReview::from).collect()\n        }\n        ForgeName::GitLab => {\n            let preferred_account = preferred_forge_user\n                .as_ref()","sourceCodeStart":653,"sourceCodeEnd":689,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-forge/src/review.rs#L653-L689","documentation":"In list_recently_settled_reviews (crates/but-forge/src/review.rs), the GitHub branch spawns a thread and creates a fresh tokio Runtime inside it. If Runtime::new() fails, this error is returned. Runtime::new() typically fails only when the OS cannot allocate the resources the runtime needs (threads/io driver).","triggerScenarios":"tokio::runtime::Runtime::new() returns Err inside the spawned thread while sweeping recently closed GitHub PRs — e.g. OS out of memory, thread-creation limits, or inability to initialize the IO driver.","commonSituations":"Container/resource-limited environments hitting thread or memory caps; heavily loaded CI machines; RLIMIT settings blocking thread creation.","solutions":["Free system resources / raise thread and memory limits on the host","Use Handle::current() or a shared static runtime instead of building a new Runtime per call","Retry the sync after transient resource pressure subsides","Log the underlying std::io::Error to confirm which resource failed"],"exampleFix":"// before\ntokio::runtime::Runtime::new().map_err(|e| anyhow::anyhow!(\"Failed to create a runtime for the settled-review sweep: {e}\"))?\n// after\n// run on an existing runtime via tokio::runtime::Handle::current().block_on(...) so Runtime::new() is never called","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match list_recently_settled_reviews(...) {\n    Ok(reviews) => reviews,\n    Err(e) if e.to_string().contains(\"Failed to create a runtime\") => {\n        std::thread::sleep(Duration::from_secs(2));\n        retry_with_backoff(|| list_recently_settled_reviews(...), 3)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Reuse a shared tokio runtime rather than creating one per call","Monitor host memory/thread headroom before syncs","Avoid running this in heavily resource-capped environments"],"tags":["rust","tokio","runtime","resources"],"backgroundTag":"module-init-failed","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"}