stablyai/orca · warning · AggregateError

Failed to clean up Claude login artifacts.

Error message

Failed to clean up Claude login artifacts.

What it means

Thrown by cleanupClaudeLoginArtifacts as an AggregateError wrapping one or more errors collected during cleanup of a Claude login attempt (keychain credential deletion/restore and recursive removal of the temp config dir). Each subsystem is tried independently and failures are accumulated, so the AggregateError's `errors` array holds the original causes. This indicates cleanup partially or fully failed after the login flow, not that the login itself failed.

Source

Thrown at src/cli/handlers/account.ts:174

      errors.push(error)
    }
    if (restoreLegacyCredentials) {
      try {
        await (legacyCredentials
          ? writeActiveClaudeKeychainCredentials(legacyCredentials)
          : deleteActiveClaudeKeychainCredentialsStrict())
      } catch (error) {
        errors.push(error)
      }
    }
  }
  try {
    rmSync(configDir, { recursive: true, force: true })
  } catch (error) {
    errors.push(error)
  }
  if (errors.length > 0) {
    throw new AggregateError(errors, 'Failed to clean up Claude login artifacts.')
  }
}

/** Logs into a Claude account in a temp config dir, then registers it with the local runtime. */
async function addClaudeAccount({ client, json }: HandlerContext): Promise<void> {
  const configDir = mkdtempSync(join(tmpdir(), 'orca-account-add-claude-'))
  const session: InteractiveLoginSession = {
    child: null,
    registering: false,
    terminationPromise: null
  }
  let legacyCredentials: string | null = null
  let restoreLegacyCredentials = false
  const result = await withInteractiveLoginCleanup(
    session,
    async () => {
      await cleanupClaudeLoginArtifacts(configDir, legacyCredentials, restoreLegacyCredentials)
    },

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Inspect error.errors array for each underlying cause and address the dominant one.
  2. On macOS, ensure keychain is unlocked and the process has keychain access; rerun cleanup manually.
  3. Manually remove the temp dir (`rm -rf /tmp/orca-account-add-claude-*`) if rmSync failed due to locks.
  4. Re-run the account add flow once the blocker (locked keychain, AV lock) is cleared.

Example fix

// before: AggregateError from cleanup
try {
  await cleanupClaudeLoginArtifacts(configDir, legacyCreds, restore)
} catch (e) {
  // surfaced as AggregateError, causes hidden
}

// after: surface each cause
if (e instanceof AggregateError) {
  for (const cause of e.errors) console.error(cause)
}
Defensive patterns

Strategy: try-catch

Validate before calling

import { accessSync, constants } from 'node:fs'

function canRemoveDir(dir: string): boolean {
  try {
    accessSync(dir, constants.W_OK)
    return true
  } catch {
    return false
  }
}

Type guard

function isAggregateError(e: unknown): e is AggregateError {
  return e instanceof AggregateError
}

Try / catch

try {
  await addClaudeAccount(ctx)
} catch (e) {
  if (e instanceof AggregateError) {
    for (const cause of e.errors) console.error('cleanup failure:', cause)
    // login may have succeeded; treat cleanup errors as non-fatal
  } else {
    throw e
  }
}

Prevention

When it happens

Trigger: Any of the following fail: deleteActiveClaudeKeychainCredentialsStrict(configDir), legacy credential restore/write, or rmSync(configDir, {recursive:true,force:true}). At least one push to the `errors` array occurs and errors.length > 0.

Common situations: macOS Keychain access denied or locked during cleanup, the temp config dir held open file handles (another process, antivirus), permission errors on removal, or partial state from an interrupted previous run.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/22728f37c95b4b6d. Report an issue: GitHub.