From 1cf4ea68b88a0827dd9bba8bc607cabdd77db37e Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 23 Nov 2026 12:34:50 +0000 Subject: [PATCH] Type-erase the ChatGPT token refresh future (#63332) Return a boxed `dyn Future` from `refresh_and_persist_chatgpt_token` so callers share the code that polls the refresh future. GitOrigin-RevId: e0a47f585348306145600561cc086676ffaceed5 --- codex-rs/login/src/auth/manager.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/codex-rs/login/src/auth/manager.rs b/codex-rs/login/src/auth/manager.rs index 42a2830a2a..02b652e3c9 100644 --- a/codex-rs/login/src/auth/manager.rs +++ b/codex-rs/login/src/auth/manager.rs @@ -3604,12 +3604,8 @@ impl AuthManager { "Token data is not available.", )) })?; - Box::pin(self.refresh_and_persist_chatgpt_token( - chatgpt_auth, - token_data, - reason, - )) - .await + self.refresh_and_persist_chatgpt_token(chatgpt_auth, token_data, reason) + .await } Some( CodexAuth::ApiKey(_) @@ -3777,9 +3773,19 @@ impl AuthManager { .map_err(|error| external_auth.classify_error(std::io::Error::other(error))) } + // Erase the future's type so callers share the code that polls it. + fn refresh_and_persist_chatgpt_token<'a>( + &'a self, + auth: &'a ChatgptAuth, + tokens: TokenData, + reason: RefreshReason, + ) -> Pin> + Send + 'a>> { + Box::pin(self.refresh_and_persist_chatgpt_token_impl(auth, tokens, reason)) + } + // Refreshes ChatGPT OAuth tokens, persists the updated auth state, and // reloads the in-memory cache so callers immediately observe new tokens. - async fn refresh_and_persist_chatgpt_token( + async fn refresh_and_persist_chatgpt_token_impl( &self, auth: &ChatgptAuth, tokens: TokenData,