mirror of
https://github.com/cline/cline.git
synced 2026-09-02 07:42:19 +08:00
fix: prevent logout on network errors during token refresh (#8021)
* fix: prevent logout on network errors during token refresh When network errors occur at startup (e.g., opening laptop while offline), users were being logged out because the token refresh failed and returned null to AuthService. Now on network errors or max retries exceeded, we return the stored auth data instead of clearing the session. This keeps users logged in with their existing credentials. If the token is truly invalid, the actual API request will fail later when the user tries to use Cline, rather than logging them out preemptively at startup. * chore: add changeset
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"claude-dev": patch
|
||||
---
|
||||
|
||||
Fixed an issue where users were being logged out when opening the extension with network issues (e.g., opening laptop while offline). Now the extension retains your login state and will retry authentication when you make a request.
|
||||
@@ -210,11 +210,9 @@ export class ClineAuthProvider implements IAuthProvider {
|
||||
|
||||
// Check if we've exceeded max retries
|
||||
if (this.refreshRetryCount >= this.MAX_REFRESH_RETRIES) {
|
||||
return this.clearSession(
|
||||
controller,
|
||||
`Max refresh retries (${this.MAX_REFRESH_RETRIES}) exceeded. Clearing auth state.`,
|
||||
storedAuthData,
|
||||
)
|
||||
Logger.error(`Max refresh retries (${this.MAX_REFRESH_RETRIES}) exceeded.`)
|
||||
// Don't clear session - return stored data and let API request fail later
|
||||
return storedAuthData
|
||||
}
|
||||
|
||||
// Try to refresh the token using the refresh token
|
||||
@@ -249,8 +247,9 @@ export class ClineAuthProvider implements IAuthProvider {
|
||||
throw refreshError
|
||||
}
|
||||
|
||||
// For network errors, return null and let retry logic handle it
|
||||
return null
|
||||
// For network errors, return stored data - let the API request fail later
|
||||
// when the user actually tries to use Cline, not at startup
|
||||
return storedAuthData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user