{"record":{"id":"2adc67aacf0b62e6","repo":"toeverything/AFFiNE","slug":"failed-to-revoke-auth-session","errorCode":null,"errorMessage":"Failed to revoke auth session","messagePattern":"Failed to revoke auth session","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/apps/electron/src/main/auth/auth-session.ts","lineNumber":219,"sourceCode":"export async function revokeAuthSession(endpoint: string) {\n  const normalized = normalizeEndpoint(endpoint);\n  await getAuthSessionBroker(normalized).revoke(\n    'sign-out',\n    async (refreshToken: string) => {\n      const response = await authFetch(\n        new URL('/api/auth/session/revoke', normalized).toString(),\n        {\n          method: 'POST',\n          headers: {\n            'content-type': 'application/json',\n            'x-affine-client-kind': 'native',\n            'x-affine-version': BUILD_CONFIG.appVersion,\n          },\n          body: JSON.stringify({ refreshToken }),\n          signal: AbortSignal.timeout(AUTH_REQUEST_TIMEOUT),\n        }\n      );\n      if (!response.ok) throw new Error('Failed to revoke auth session');\n    }\n  );\n}\n\nexport async function clearAuthSession(endpoint: string, reason: string) {\n  await getAuthSessionBroker(endpoint).clear(reason);\n}\n\nexport async function getValidAccessToken(\n  endpoint: string,\n  minValidity = 60_000\n) {\n  try {\n    return await getAuthSessionBroker(endpoint).getValidAccessToken(\n      minValidity\n    );\n  } catch (error) {\n    const classified = classifyAuthError(error);","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/apps/electron/src/main/auth/auth-session.ts#L201-L237","documentation":"revokeAuthSession posts the refresh token to the server's session revoke endpoint; the underlying request wrapper throws 'Failed to revoke auth session' when the server rejects the revocation, so sign-out failures surface instead of leaving a live session.","triggerScenarios":"Thrown at packages/frontend/apps/electron/src/main/auth/auth-session.ts:219 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry sign-out; the revocation request to the auth server failed.","Check network connectivity to the auth server.","Clear the local session if the server-side session is already gone; the local state will be reset regardless."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}