stablyai/orca · error · AggregateError

Failed to invalidate Codex session backfill marker

Error message

Failed to invalidate Codex session backfill marker

What it means

Thrown as AggregateError when invalidating the Codex session backfill completion marker fails twice: first rmSync(markerPath, {force:true}) threw, then the fallback writeFileAtomically to overwrite the marker with {version:0, invalidatedAt} also threw. Both original errors are aggregated so the caller sees both causes. A stuck marker would suppress the next backfill opt-in, so this is surfaced rather than swallowed.

Source

Thrown at src/main/codex/codex-session-backfill-marker.ts:85

    )}\n`
  )
}

export function invalidateCodexSessionBackfillMarker(markerPath: string): void {
  markerInvalidationGeneration += 1
  try {
    // Why: a managed-lane system-default launch can create new source
    // rollouts, so a prior one-time marker must not suppress the next opt-in.
    rmSync(markerPath, { force: true })
  } catch (error) {
    console.warn('[codex-session-backfill] Failed to invalidate completion marker:', error)
    try {
      writeFileAtomically(
        markerPath,
        `${JSON.stringify({ version: 0, invalidatedAt: Date.now() })}\n`
      )
    } catch (fallbackError) {
      throw new AggregateError(
        [error, fallbackError],
        'Failed to invalidate Codex session backfill marker'
      )
    }
  }
}

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Check permissions on dirname(markerPath) — the Orca process needs write/delete access.
  2. Free disk space if full.
  3. On Windows, ensure no process holds an exclusive lock on the marker file.
  4. Verify the marker path is still valid after any CODEX_HOME / userData relocation.
  5. Manually delete the marker file if the process cannot, then let Orca recreate it.
Defensive patterns

Strategy: try-catch

Validate before calling

import { access, constants } from 'node:fs/promises'
import { dirname } from 'node:path'
try {
  await access(dirname(markerPath), constants.W_OK | constants.X_OK)
} catch {
  // marker dir not writable; skip invalidation or fix permissions first
}

Type guard

function isBackfillMarkerInvalidationError(error: unknown): boolean {
  return error instanceof AggregateError && error.message === 'Failed to invalidate Codex session backfill marker'
}

Try / catch

try {
  invalidateCodexSessionBackfillMarker(markerPath)
} catch (error) {
  if (error instanceof AggregateError) {
    // both rm and overwrite failed; log and continue — a stale marker only suppresses one backfill opt-in
    console.warn('marker invalidation failed; will retry on next launch', error.errors)
  } else throw error
}

Prevention

When it happens

Trigger: The marker file's directory has restrictive permissions (rm and write both denied); the marker path is on a read-only filesystem; the parent directory was deleted; an OS file lock (Windows) blocks both delete and write; disk is full so the atomic temp write fails.

Common situations: Permissions on the Orca state directory were tightened; the state dir is on a read-only mount; antivirus locking on Windows; disk-full; the path is invalid after a home-directory change.

Related errors


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