fix: unexpected re-auth when auth-token is expired (#549)

This commit is contained in:
Mingholy
2025-09-09 11:34:05 +08:00
committed by GitHub
parent 60c136ad67
commit 621fe2e8ba
5 changed files with 448 additions and 144 deletions

View File

@@ -153,17 +153,10 @@ export class QwenContentGenerator extends OpenAIContentGenerator {
return await attemptOperation();
} catch (error) {
if (this.isAuthError(error)) {
try {
// Use SharedTokenManager to properly refresh and persist the token
// This ensures the refreshed token is saved to oauth_creds.json
await this.sharedManager.getValidCredentials(this.qwenClient, true);
// Retry the operation once with fresh credentials
return await attemptOperation();
} catch (_refreshError) {
throw new Error(
'Failed to obtain valid Qwen access token. Please re-authenticate.',
);
}
// Use SharedTokenManager to properly refresh and persist the token
// This ensures the refreshed token is saved to oauth_creds.json
await this.sharedManager.getValidCredentials(this.qwenClient, true);
return await attemptOperation();
}
throw error;
}