affaan-m/ECC · warning

Formatter exited with status ${result.status}

Error message

Formatter exited with status ${result.status}

What it means

When the Windows .cmd formatter is spawned and exits with a non-zero status but writes nothing to stderr, the hook throws a status-only message. Like the other formatter errors it is caught and swallowed, so the edit is not blocked; the file is simply left unformatted.

Source

Thrown at scripts/hooks/post-edit-format.js:70

        // Biome: `check --write` = format + lint in one pass
        // Prettier: `--write` = format only
        const args = formatter === 'biome' ? [...resolved.prefix, 'check', '--write', resolvedFilePath] : [...resolved.prefix, '--write', resolvedFilePath];

        if (process.platform === 'win32' && resolved.bin.endsWith('.cmd')) {
          // Windows: .cmd files require shell to execute. Guard against
          // command injection by rejecting paths with shell metacharacters.
          if (UNSAFE_PATH_CHARS.test(resolvedFilePath)) {
            throw new Error('File path contains unsafe shell characters');
          }
          const result = spawnSync(resolved.bin, args, {
            cwd: projectRoot,
            shell: true,
            stdio: 'pipe',
            timeout: 15000
          });
          if (result.error) throw result.error;
          if (typeof result.status === 'number' && result.status !== 0) {
            throw new Error(result.stderr?.toString() || `Formatter exited with status ${result.status}`);
          }
        } else {
          execFileSync(resolved.bin, args, {
            cwd: projectRoot,
            stdio: ['pipe', 'pipe', 'pipe'],
            timeout: 15000
          });
        }
      } catch {
        // Formatter not installed, file missing, or failed — non-blocking
      }
    }
  } catch {
    // Invalid input — pass through
  }

  return rawInput;
}

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run the formatter manually on the file to see the real diagnostic
  2. Fix any syntax errors in the edited file
  3. Reinstall or upgrade the formatter (biome/prettier) in the project
Defensive patterns

Strategy: try-catch

Validate before calling

const { spawnSync } = require('child_process');
function formatterOkay(bin, projectRoot) {
  const r = spawnSync(bin, ['--version'], { cwd: projectRoot });
  return !r.error && r.status === 0;
}

Type guard

function isFormatterStatusZero(result) {
  return result && !result.error && (typeof result.status !== 'number' || result.status === 0);
}

Try / catch

try { runFormatter(bin, args); }
catch (err) {
  if (/Formatter exited with status/.test(err.message)) {
    console.warn('Formatter failed; run it manually to see diagnostics:', err.message);
    return; // non-blocking
  }
  throw err;
}

Prevention

When it happens

Trigger: Biome or Prettier exits non-zero on the edited file (syntax error, unsupported syntax, config error) while emitting no stderr output; or the formatter binary is partially broken on Windows.

Common situations: Editing a file with a syntax error the formatter cannot parse, a formatter version that chokes on a new syntax feature, or a corrupt formatter install that exits non-zero silently.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/2862db27f9d7c545. Report an issue: GitHub.