mirror of
https://github.com/openai/codex.git
synced 2026-09-15 12:08:01 +00:00
metadata timeout
This commit is contained in:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user