openai/codex · error

timed out after refreshing OAuth tokens for server

Error message

timed out after {refresh_request_timeout:?} refreshing OAuth tokens for server {}

What it means

Fired in refresh_transaction when the underlying OAuth token refresh HTTP exchange did not complete within refresh_request_timeout; the future was dropped/timed out, so tokens remain unrefreshed and the error surfaces to the caller as a failed refresh for that MCP server.

Solutions

  1. Retry the token refresh, ideally after a short backoff
  2. Check network connectivity and authorization server latency
  3. Increase the refresh request timeout if the server is known to be slow
  4. Verify the authorization server's token endpoint is reachable
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at codex-rs/rmcp-client/src/oauth/refresh_transaction.rs:225 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/e51666e25b043f83. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/rmcp-client/src/oauth/refresh_transaction.rs:225

            }
            Ok(Err(error)) => {
                warn!(
                    error = %error,
                    "MCP OAuth provider refresh failed"
                );
                return Err(error).with_context(|| {
                    format!(
                        "failed to refresh OAuth tokens for server {}",
                        self.inner.server_name
                    )
                });
            }
            Err(_) => {
                warn!(
                    timeout_ms = refresh_request_timeout.as_millis(),
                    "MCP OAuth provider refresh timed out; the outcome is unknown and a later serialized retry is permitted"
                );
                anyhow::bail!(
                    "timed out after {refresh_request_timeout:?} refreshing OAuth tokens for server {}",
                    self.inner.server_name
                );
            }
        };

        // Persist to the pinned source before exposing the refreshed token. On failure, restore
        // the prior in-process credential and return the error; serving an unpersisted token would
        // hide the root cause until a later process restart. If the provider already consumed the
        // prior token, the next refresh may require reauthorization. That is the deliberate
        // fail-closed policy.
        // TODO: Add a bounded persistence retry only if telemetry shows this is common; never
        // silently switch stores or continue with an unpersisted credential.
        debug!("persisting refreshed MCP OAuth credentials to the resolved store");
        if let Err(error) =
            self.inner
                .credential_store
                .save(keyring_store, &self.inner.server_name, &refreshed)

View on GitHub (pinned to 339751715c)