Retry transient registry failures during initial exec connection (#39777)

## What changed

- Retry transient environment-registry failures while opening the initial Noise rendezvous connection, including timeouts, interrupted response bodies, retryable HTTP statuses, and temporarily offline environments.
- Bound registry attempts with per-request and overall timeouts, exponential backoff, and a retry limit while returning permanent registry errors immediately.
- Preserve the existing one-time bundle refresh after an unauthorized WebSocket handshake, with a fresh registry retry window.
- Treat malformed complete JSON responses as terminal rather than retryable transport failures.

## Testing

- Cover transient and permanent registry responses, stalled requests, retry limits and deadlines, interrupted bodies, malformed JSON, unauthorized bundle refresh, and session-resume behavior.

GitOrigin-RevId: 5929274103702ad477e7a638ab489319a43a93fa
This commit is contained in:
richardopenai authored and copyberry committed 2026-08-20 18:48:17 +00:00
1 parent 5cada24434
commit 5663754f62
6 files changed
+587 -50

No files matched your search

@@ -37,13 +37,31 @@ fn registry_recovery_retry_delay_exponentially_backs_off_and_caps() {
#[test]
fn recovery_retries_transient_registry_errors() {
let error = registry_error(http::StatusCode::TOO_MANY_REQUESTS, /*code*/ None);
for status in [
http::StatusCode::REQUEST_TIMEOUT,
http::StatusCode::TOO_MANY_REQUESTS,
http::StatusCode::INTERNAL_SERVER_ERROR,
http::StatusCode::BAD_GATEWAY,
http::StatusCode::SERVICE_UNAVAILABLE,
] {
let error = registry_error(status, /*code*/ None);
assert!(is_retryable_registry_error(&error));
assert!(is_retryable_recovery_error(&error));
assert!(is_retryable_recovery_error(
&ExecServerError::ConnectionAttempt(Arc::new(error))
));
}
}
#[test]
fn recovery_retries_registry_request_timeouts() {
let error = ExecServerError::EnvironmentRegistryRequest(
codex_http_client::RouteAwareRequestError::Timeout,
);
assert!(is_retryable_registry_error(&error));
assert!(is_retryable_recovery_error(&error));
assert!(is_retryable_recovery_error(
&ExecServerError::ConnectionAttempt(Arc::new(error))
));
}
#[test]