thedotmack/claude-mem · warning

statfsSync failed; proceeding without disk-space pre-flight

Error message

statfsSync failed; proceeding without disk-space pre-flight

What it means

The v12.4.3 cleanup backs up the SQLite DB and first stats the target filesystem with statfsSync to confirm room for dbSize * 1.2 + 100 MB. If statfsSync throws, this warning is logged and the migration continues without the disk-space pre-flight. The backup still runs; only the early 'not enough space' abort is skipped, so a full disk now surfaces later as a VACUUM INTO or copyFileSync failure instead.

Source

Thrown at src/services/infrastructure/CleanupV12_4_3.ts:130

  logger.info('SYSTEM', 'v12.4.3 cleanup --dry-run scan complete', {
    observerSessions: counts.observerSessions,
    observerCascadeRows: counts.observerCascadeRows,
    stuckPendingMessages: counts.stuckPendingMessages,
  });
  return counts;
}

function executeCleanup(dbPath: string, effectiveDataDir: string, markerPath: string): void {
  const dbSize = statSync(dbPath).size;
  const required = Math.ceil(dbSize * 1.2) + 100 * 1024 * 1024;

  let backupPath: string | null = null;
  let fsStats: ReturnType<typeof statfsSync> | undefined;
  try {
    fsStats = statfsSync(effectiveDataDir);
  } catch (err: unknown) {
    const error = err instanceof Error ? err : new Error(String(err));
    logger.warn('SYSTEM', 'statfsSync failed; proceeding without disk-space pre-flight', {}, error);
  }

  if (fsStats) {
    const bsize = Number(fsStats.bsize);
    const bavail = Number(fsStats.bavail);

    // Bun <= 1.3.14 on darwin-x64 returns a misaligned statfs struct
    // (bsize = 0, fields shifted by one slot). Tracking issue:
    //   https://github.com/oven-sh/bun/issues/31133
    // Fix landed upstream in:
    //   https://github.com/oven-sh/bun/pull/31139
    // and will ship in the next Bun release after 1.3.14. Until then, any
    // `bavail * bsize` math returns 0 and this gate would permanently skip
    // the cleanup with a misleading `free=0` error. Treat non-credible
    // readings (bsize <= 0, NaN, or non-finite) as "skip the gate" rather
    // than "disk is full" -- a real out-of-space condition will still
    // surface from the subsequent VACUUM INTO / copyFileSync.
    if (!Number.isFinite(bsize) || !Number.isFinite(bavail) || bsize <= 0) {

View on GitHub (pinned to e2d1df569a)

Solutions

  1. Confirm the data directory exists and its mount is live before the cleanup/upgrade runs.
  2. Read the logged error: ENOENT means the dir is missing, EACCES means permission trouble, EIO hints at a bad mount.
  3. Manually verify free space (df on the data dir) covers dbSize * 1.2 + 100 MB, since the automatic pre-flight was skipped.
  4. Fix the data dir configuration (env/config pointing at the wrong path), then re-run.
Defensive patterns

Strategy: fallback

Validate before calling

// replace the skipped pre-flight with your own space check before upgrading
import { statfsSync, existsSync, statSync } from 'node:fs';

if (existsSync(dataDir)) {
  const need = Math.ceil(statSync(dbPath).size * 1.2) + 100 * 1024 * 1024;
  const fs = statfsSync(dataDir);
  const free = Number(fs.bsize) * Number(fs.bavail);
  if (free < need) throw new Error(`need ${need} bytes, only ${free} free`);
}

Prevention

When it happens

Trigger: statfsSync(effectiveDataDir) throws: the data directory does not exist yet, sits on an unmounted/unavailable network mount, lacks stat permissions, or the filesystem does not support statfs from the runtime.

Common situations: First run before the data dir is created; data dir on a disconnected NFS/SMB mount; FUSE or unusual filesystems; containerized runs with a misconfigured or missing volume mount for the data dir.

Related errors


AI-assisted analysis of thedotmack/claude-mem@e2d1df569a (2026-08-20). Data as JSON: /api/errors/5881e1be3b9c06b9. Report an issue: GitHub.