mirror of
https://github.com/openai/codex.git
synced 2026-11-23 07:17:11 +00:00
Defer Noise environment connections until registration (#33166)
## What changed - Replace pending WebSocket URL registration with deferred Noise environment registration that gates connection attempts on an explicit readiness signal. - Reuse the Noise rendezvous transport after readiness so reconnects request a fresh connection bundle. - Preserve terminal errors for failed or dropped registrations and keep late completion isolated from replacement environments. ## Testing - Add coverage for readiness gating, registration failure and replacement, eager Noise connections, and reconnection through a fresh rendezvous bundle. GitOrigin-RevId: 83e23fa03a02e3b2bdf1a83fe26d7ac461f55cf3
This commit is contained in:
1 parent
5d325ba223
commit
32cd5d4eab
9 files changed
+369
-216
No files matched your search
@@ -94,27 +94,35 @@ impl ExecServerClient {
|
||||
pub(crate) async fn connect_for_transport(
|
||||
transport_params: ExecServerTransportParams,
|
||||
) -> Result<Self, ExecServerError> {
|
||||
let (transport_params, deferred_readiness) = match transport_params {
|
||||
ExecServerTransportParams::Deferred(deferred) => {
|
||||
(deferred.transport, Some(deferred.readiness))
|
||||
}
|
||||
transport_params => (transport_params, None),
|
||||
};
|
||||
|
||||
if let Some(readiness) = deferred_readiness {
|
||||
readiness
|
||||
.await
|
||||
.unwrap_or_else(|_| {
|
||||
Err("environment registration ended before completion".to_string())
|
||||
})
|
||||
.map_err(|message| {
|
||||
ExecServerError::Disconnected(format!("environment unavailable: {message}"))
|
||||
})?;
|
||||
}
|
||||
|
||||
let (websocket_url, connect_timeout, initialize_timeout) = match transport_params {
|
||||
ExecServerTransportParams::Deferred(_) => {
|
||||
return Err(ExecServerError::Protocol(
|
||||
"nested deferred exec-server transports are unsupported".to_string(),
|
||||
));
|
||||
}
|
||||
ExecServerTransportParams::WebSocketUrl {
|
||||
websocket_url,
|
||||
connect_timeout,
|
||||
initialize_timeout,
|
||||
} => (websocket_url, connect_timeout, initialize_timeout),
|
||||
ExecServerTransportParams::PendingWebSocketUrl(websocket_url) => {
|
||||
let websocket_url = websocket_url
|
||||
.await
|
||||
.unwrap_or_else(|_| {
|
||||
Err("environment registration ended before completion".to_string())
|
||||
})
|
||||
.map_err(|message| {
|
||||
ExecServerError::Disconnected(format!("environment unavailable: {message}"))
|
||||
})?;
|
||||
(
|
||||
websocket_url,
|
||||
DEFAULT_REMOTE_EXEC_SERVER_CONNECT_TIMEOUT,
|
||||
DEFAULT_REMOTE_EXEC_SERVER_INITIALIZE_TIMEOUT,
|
||||
)
|
||||
}
|
||||
ExecServerTransportParams::NoiseRendezvous { provider, identity } => {
|
||||
let reconnect_strategy = ExecServerReconnectStrategy::NoiseRendezvous {
|
||||
provider: Arc::clone(&provider),
|
||||
|
||||
Reference in new issue
Block a user