{"record":{"id":"fe8e690122e90677","repo":"moeru-ai/airi","slug":"signout-failed","errorCode":null,"errorMessage":"signOut failed","messagePattern":"signOut failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/ui-server-auth/src/modules/profile.ts","lineNumber":169,"sourceCode":"    throw new Error(error.message ?? 'changePassword failed')\n}\n\n/**\n * Sign the current user out via better-auth's `/sign-out` endpoint.\n *\n * Use when:\n * - User clicks \"Sign out\" on the profile page.\n *\n * Returns:\n * - Resolves once the better-auth session cookie has been cleared by the\n *   server. Caller is expected to navigate the user back to the sign-in\n *   page after this resolves.\n */\nexport async function signOut(args: AuthFetchBase): Promise<void> {\n  const client = getAuthClient(args)\n  const { error } = await client.signOut()\n  if (error)\n    throw new Error(error.message ?? 'signOut failed')\n}\n\nexport function describeProfileError(error: unknown): string {\n  return errorMessageFrom(error) ?? 'Unexpected error'\n}\n\n/**\n * Normalise better-auth's `Date | string | null | undefined` createdAt into\n * the ISO string the rest of the UI expects.\n *\n * Before:\n * - `new Date('2025-04-01T00:00:00.000Z')` / `'2025-04-01T00:00:00.000Z'` / `null`\n *\n * After:\n * - `'2025-04-01T00:00:00.000Z'` / `'2025-04-01T00:00:00.000Z'` / `null`\n */\nfunction toIsoString(value: unknown): string | null {\n  if (value instanceof Date)","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/apps/ui-server-auth/src/modules/profile.ts#L151-L187","documentation":"Thrown by signOut when better-auth's client.signOut returns an error. The fallback 'signOut failed' is used only when the server error lacks a message. Normally signOut clears the session cookie server-side; a failure usually indicates a transport problem or the auth server rejecting the request.","triggerScenarios":"Clicking sign-out when the auth server is unreachable; the session cookie is already invalid/expired so /sign-out returns an error; network/CORS failure during the POST.","commonSituations":"Auth backend briefly down; the user opened multiple tabs and signed out in another already; cookie was cleared by a proxy; apiServerUrl misconfigured.","solutions":["Treat signOut failure as non-fatal: clear local client state and redirect to sign-in anyway.","Check apiServerUrl and auth server health on persistent failure.","Surface error.message if present, otherwise proceed with client-side session teardown."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await signOut(args)\n} catch {\n  // signOut failure is non-fatal: clear local session state and redirect to sign-in\n}\nclearLocalSession()\nrouter.push('/sign-in')","preventionTips":["Treat signOut as best-effort; always clear client state and redirect.","Do not block the user in the app on a signOut server error.","Check auth server health if failures are persistent."],"tags":["auth","profile","better-auth","session","ui-server-auth"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}