{"record":{"id":"524cf5dc94140d5e","repo":"eyaltoledano/claude-task-master","slug":"refresh-failed","errorCode":"REFRESH_FAILED","errorMessage":"'Failed to refresh session'","messagePattern":"'Failed to refresh session'","errorType":"exception","errorClass":"AuthenticationError","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/auth/services/session-manager.ts","lineNumber":180,"sourceCode":"\t\t\ttokenType: 'standard',\n\t\t\tsavedAt: new Date().toISOString(),\n\t\t\tselectedContext: context || undefined\n\t\t};\n\t}\n\n\t/**\n\t * Refresh authentication token using Supabase session\n\t * Note: Supabase handles token refresh automatically via the session storage adapter.\n\t * This method is mainly for explicit refresh requests.\n\t */\n\tasync refreshToken(): Promise<AuthCredentials> {\n\t\tawait this.waitForInitialization();\n\t\ttry {\n\t\t\t// Use Supabase's built-in session refresh\n\t\t\tconst session = await this.supabaseClient.refreshSession();\n\n\t\t\tif (!session) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t'Failed to refresh session',\n\t\t\t\t\t'REFRESH_FAILED'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Sync user info to context store\n\t\t\tthis.contextStore.saveContext({\n\t\t\t\tuserId: session.user.id,\n\t\t\t\temail: session.user.email\n\t\t\t});\n\n\t\t\t// Build credentials response\n\t\t\tconst context = this.contextStore.getContext();\n\t\t\tconst credentials: AuthCredentials = {\n\t\t\t\ttoken: session.access_token,\n\t\t\t\trefreshToken: session.refresh_token,\n\t\t\t\tuserId: session.user.id,\n\t\t\t\temail: session.user.email,","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/auth/services/session-manager.ts#L162-L198","documentation":"AuthenticationError with code REFRESH_FAILED thrown by SessionManager.refreshToken when supabaseClient.refreshSession() resolves without a session. Supabase's auth call did not return a refreshable session, typically because the refresh token is missing, expired, or already revoked. The method exists for explicit refresh requests; Supabase normally refreshes automatically via the storage adapter.","triggerScenarios":"Calling refreshToken() when there is no persisted session, the refresh token has expired (Supabase default ~ at least one reuse window passed), the token was already used/rotated elsewhere, or the user was signed out server-side.","commonSituations":"Long-lived CLI installations where the session expired weeks ago; logging in on another machine invalidated the refresh token; clock skew on the local machine; clearing ~/.taskmaster auth storage while still calling authenticated commands.","solutions":["Run the full login flow (task-master auth login) to obtain a fresh session","Clear stale stored credentials and re-authenticate","Check system clock skew (NTP) if the token was recently issued","Ensure no concurrent sessions are rotating the same refresh token"],"exampleFix":"// before: assuming refresh always works\nconst creds = await sessionManager.refreshToken();\n// after: re-login on REFRESH_FAILED\ntry {\n  const creds = await sessionManager.refreshToken();\n} catch (e) {\n  if (e instanceof AuthenticationError && e.code === 'REFRESH_FAILED') {\n    await sessionManager.login(); // full re-authentication\n  }\n}","handlingStrategy":"fallback","validationCode":"// check stored session expiry before attempting refresh\nconst creds = await sessionManager.getCachedCredentials?.();\nif (creds?.expiresAt && new Date(creds.expiresAt) < new Date()) {\n  await reauthenticate(); // session clearly expired\n}","typeGuard":"function isRefreshFailed(e: unknown): e is AuthenticationError {\n  return e instanceof AuthenticationError && e.code === 'REFRESH_FAILED';\n}","tryCatchPattern":"try {\n  await sessionManager.refreshToken();\n} catch (e) {\n  if (isRefreshFailed(e)) {\n    await sessionManager.login(); // full re-auth fallback\n  } else throw e;\n}","preventionTips":["Treat refresh as best-effort: always fall back to interactive re-login","Sync machine clock (NTP) to avoid premature expiry judgments","Avoid sharing one account/session across many machines concurrently","Schedule re-login before long-running automation starts"],"tags":["auth","session","token-refresh","supabase"],"backgroundTag":"token-refresh-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}