From 275ef855fac71203ffff904d20c860a7717d6e8a Mon Sep 17 00:00:00 2001 From: felixxia-oai Date: Fri, 21 Aug 2026 14:07:12 +0000 Subject: [PATCH] Allow more time for local code-mode host startup (#39940) ## What changed Use a 30-second handshake timeout for locally spawned code-mode hosts while retaining the existing 10-second timeout for WebSocket connections. GitOrigin-RevId: de1801c062b5c71d4c7b2c33a53b51e0b672445e --- codex-rs/code-mode/src/remote_session/connection.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/codex-rs/code-mode/src/remote_session/connection.rs b/codex-rs/code-mode/src/remote_session/connection.rs index 355ee6c792..4fcd188f3a 100644 --- a/codex-rs/code-mode/src/remote_session/connection.rs +++ b/codex-rs/code-mode/src/remote_session/connection.rs @@ -66,6 +66,7 @@ mod transport; const IPC_CHANNEL_CAPACITY: usize = 128; const HOST_HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(10); +const LOCAL_HOST_STARTUP_TIMEOUT: Duration = Duration::from_secs(30); // TODO(anp) make this timeout configurable if 60 seconds is insufficient. const DEFAULT_HOST_WAIT_TRANSPORT_TIMEOUT: Duration = Duration::from_secs(60); const MAX_WEBSOCKET_FRAME_BYTES: usize = MAX_FRAME_BYTES + std::mem::size_of::(); @@ -345,7 +346,11 @@ impl Connection { None => Err("code-mode host exited during handshake".to_string()), } }; - let handshake_result = match tokio::time::timeout(HOST_HANDSHAKE_TIMEOUT, handshake).await { + let handshake_timeout = match &owner { + ConnectionOwner::Process(_) => LOCAL_HOST_STARTUP_TIMEOUT, + ConnectionOwner::WebSocket => HOST_HANDSHAKE_TIMEOUT, + }; + let handshake_result = match tokio::time::timeout(handshake_timeout, handshake).await { Ok(result) => result, Err(_) => { let _ = writer.close().await;