From 9eff9b835edc3101930e2afdea5bcad4990a9cf4 Mon Sep 17 00:00:00 2001 From: pash Date: Fri, 30 Jan 2026 08:15:51 -0800 Subject: [PATCH] metadata timeout --- codex-rs/core/src/codex.rs | 40 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 4953c4c2af..0eb79f88ea 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -85,6 +85,8 @@ use serde_json::Value; use tokio::sync::Mutex; use tokio::sync::RwLock; use tokio::sync::oneshot; +use tokio::time::Duration as TokioDuration; +use tokio::time::timeout; use tokio_util::sync::CancellationToken; use tracing::Instrument; use tracing::debug; @@ -729,22 +731,30 @@ impl Session { } get_git_repo_root(cwd)?; - let git_info = collect_git_info(cwd).await?; - let latest_git_commit_hash = git_info.commit_hash; - let associated_remote_urls = get_git_remote_urls(cwd).await; - if latest_git_commit_hash.is_none() && associated_remote_urls.is_none() { - return None; - } + // On some CI environments (notably Windows), git commands can hang + // until their timeout elapses. Cap the total time we spend gathering + // optional metadata so turn startup stays responsive. + timeout(TokioDuration::from_millis(750), async { + let git_info = collect_git_info(cwd).await?; + let latest_git_commit_hash = git_info.commit_hash; + let associated_remote_urls = get_git_remote_urls(cwd).await; + if latest_git_commit_hash.is_none() && associated_remote_urls.is_none() { + return None; + } - let mut workspaces = BTreeMap::new(); - workspaces.insert( - cwd.to_string_lossy().into_owned(), - TurnMetadataWorkspace { - associated_remote_urls, - latest_git_commit_hash, - }, - ); - serde_json::to_string(&TurnMetadata { workspaces }).ok() + let mut workspaces = BTreeMap::new(); + workspaces.insert( + cwd.to_string_lossy().into_owned(), + TurnMetadataWorkspace { + associated_remote_urls, + latest_git_commit_hash, + }, + ); + serde_json::to_string(&TurnMetadata { workspaces }).ok() + }) + .await + .ok() + .flatten() } #[allow(clippy::too_many_arguments)]