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:
Saoud Rizwan
2025-12-10 10:33:00 -08:00
committed by GitHub
parent 4eda267981
commit 279e371cf5
2 changed files with 11 additions and 7 deletions
+5
View File
@@ -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
}
}