moeru-ai/airi · warning · Error

signOut failed

Error message

signOut failed

What it means

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.

Source

Thrown at apps/ui-server-auth/src/modules/profile.ts:169

    throw new Error(error.message ?? 'changePassword failed')
}

/**
 * Sign the current user out via better-auth's `/sign-out` endpoint.
 *
 * Use when:
 * - User clicks "Sign out" on the profile page.
 *
 * Returns:
 * - Resolves once the better-auth session cookie has been cleared by the
 *   server. Caller is expected to navigate the user back to the sign-in
 *   page after this resolves.
 */
export async function signOut(args: AuthFetchBase): Promise<void> {
  const client = getAuthClient(args)
  const { error } = await client.signOut()
  if (error)
    throw new Error(error.message ?? 'signOut failed')
}

export function describeProfileError(error: unknown): string {
  return errorMessageFrom(error) ?? 'Unexpected error'
}

/**
 * Normalise better-auth's `Date | string | null | undefined` createdAt into
 * the ISO string the rest of the UI expects.
 *
 * Before:
 * - `new Date('2025-04-01T00:00:00.000Z')` / `'2025-04-01T00:00:00.000Z'` / `null`
 *
 * After:
 * - `'2025-04-01T00:00:00.000Z'` / `'2025-04-01T00:00:00.000Z'` / `null`
 */
function toIsoString(value: unknown): string | null {
  if (value instanceof Date)

View on GitHub (pinned to 27111382b4)

Solutions

  1. Treat signOut failure as non-fatal: clear local client state and redirect to sign-in anyway.
  2. Check apiServerUrl and auth server health on persistent failure.
  3. Surface error.message if present, otherwise proceed with client-side session teardown.
Defensive patterns

Strategy: fallback

Try / catch

try {
  await signOut(args)
} catch {
  // signOut failure is non-fatal: clear local session state and redirect to sign-in
}
clearLocalSession()
router.push('/sign-in')

Prevention

When it happens

Trigger: 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.

Common situations: Auth backend briefly down; the user opened multiple tabs and signed out in another already; cookie was cleared by a proxy; apiServerUrl misconfigured.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/fe8e690122e90677. Report an issue: GitHub.