From 2817866a327ee07a4ef46eb7d0a5fd0031e2a231 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Fri, 1 May 2026 20:24:17 +0200 Subject: [PATCH] fix: reduce ConfigBuilder::build stack usage (#20650) ## Why `ConfigBuilder::build` performs a large amount of async config loading. Leaving that entire future on the caller stack makes config startup more fragile on small runtime worker stacks. ## What changed - keep `ConfigBuilder::build` as a thin wrapper that boxes the config-loading future before awaiting it - move the existing implementation into a private `build_inner` method so the large async state machine lives on the heap instead of the runtime thread stack ## Testing - Not run locally --- codex-rs/core/src/config/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs index 4b55da026..20b2a923f 100644 --- a/codex-rs/core/src/config/mod.rs +++ b/codex-rs/core/src/config/mod.rs @@ -923,6 +923,11 @@ impl ConfigBuilder { } pub async fn build(self) -> std::io::Result { + // Keep the large config-loading future off small runtime thread stacks. + Box::pin(self.build_inner()).await + } + + async fn build_inner(self) -> std::io::Result { let Self { codex_home, cli_overrides,