From 2c77888b21ff592880f2a62cde607ba6772f0292 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 23 Nov 2026 12:34:59 +0000 Subject: [PATCH] Share config-loading future poll code across callers (#63336) Return a `BoxFuture` directly from `Config::load_config_with_layer_stack` so callers share the future's poll code. Keep the large config-loading future on the heap to limit stack use on small test threads. GitOrigin-RevId: 50cf5c27983b38044ecd25dd9be4316c4fdf36ba --- codex-rs/core/src/config/mod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs index a34600ebd0..415151d072 100644 --- a/codex-rs/core/src/config/mod.rs +++ b/codex-rs/core/src/config/mod.rs @@ -152,6 +152,8 @@ use codex_utils_path_uri::LegacyAppPathString; use codex_utils_path_uri::PathConvention; use codex_utils_path_uri::PathUri; use codex_utils_path_uri::Platform; +use futures::FutureExt; +use futures::future::BoxFuture; use http::HeaderValue; use rmcp::model::ElicitationCapability; use rmcp::model::FormElicitationCapability; @@ -3539,16 +3541,16 @@ impl Config { .await } - pub(crate) async fn load_config_with_layer_stack( + pub(crate) fn load_config_with_layer_stack( fs: &dyn ExecutorFileSystem, mut cfg: ConfigToml, overrides: ConfigOverrides, codex_home: AbsolutePathBuf, config_layer_stack: ConfigLayerStack, - ) -> std::io::Result { + ) -> BoxFuture<'_, std::io::Result> { + // Keep the large future off small test thread stacks and share its poll code across callers. + async move { config_layer_stack.validate_project_mitm_profiles()?; - // Keep the large config-construction future off small test thread stacks. - Box::pin(async move { if cfg.experimental_thread_store_endpoint.is_some() { return Err(std::io::Error::new( std::io::ErrorKind::InvalidInput, @@ -5138,8 +5140,8 @@ impl Config { config.startup_warnings.push(message.to_string()); } Ok(config) - }) - .await + } + .boxed() } /// If `path` is `Some`, attempts to read the file at the given path and