affaan-m/ECC · warning
--exit-code with --watch requires --watch-count so the proce
Error message
--exit-code with --watch requires --watch-count so the process can exit
What it means
A cross-flag validation in parseArgs: combining --exit-code (non-zero exit when loops look stuck) with --watch (continuous refresh loop) requires --watch-count so the process has a deterministic stopping point. Without a count, --watch would loop forever and --exit-code could never reliably terminate the process, so the script refuses the ambiguous combination.
Source
Thrown at scripts/loop-status.js:126
options.exitCode = true;
} else if (arg === '--watch') {
options.watch = true;
} else if (arg === '--watch-count') {
options.watchCount = readPositiveInteger(readValue(args, index, arg), arg);
index += 1;
} else if (arg === '--watch-interval-seconds') {
options.watchIntervalSeconds = readPositiveNumber(readValue(args, index, arg), arg);
index += 1;
} else if (arg === '--write-dir') {
options.writeDir = readValue(args, index, arg);
index += 1;
} else {
throw new Error(`Unknown option: ${arg}`);
}
}
if (options.exitCode && options.watch && options.watchCount === null) {
throw new Error('--exit-code with --watch requires --watch-count so the process can exit');
}
return options;
}
function normalizeOptions(options = {}) {
return {
...options,
bashTimeoutSeconds: options.bashTimeoutSeconds ?? DEFAULT_BASH_TIMEOUT_SECONDS,
exitCode: Boolean(options.exitCode),
limit: options.limit ?? DEFAULT_LIMIT,
transcriptPaths: options.transcriptPaths || [],
watch: Boolean(options.watch),
watchCount: options.watchCount ?? null,
wakeGraceMultiplier: options.wakeGraceMultiplier ?? DEFAULT_WAKE_GRACE_MULTIPLIER,
watchIntervalSeconds: options.watchIntervalSeconds ?? DEFAULT_WATCH_INTERVAL_SECONDS,
writeDir: options.writeDir || null,
};View on GitHub (pinned to 01e15490f0)
Solutions
- Add --watch-count N, e.g. `--exit-code --watch --watch-count 10`.
- If you do not need continuous refresh, drop --watch and rely on a single-shot --exit-code run.
- If you do not need an exit gate, drop --exit-code and let --watch run unbounded (still requires Ctrl-C).
Example fix
# before node scripts/loop-status.js --exit-code --watch # after node scripts/loop-status.js --exit-code --watch --watch-count 10
Defensive patterns
Strategy: validation
Validate before calling
function validateFlagCombinations(opts) {
if (opts.exitCode && opts.watch && (opts.watchCount === null || opts.watchCount === undefined)) {
throw new Error('--exit-code with --watch requires --watch-count so the process can exit');
}
} Try / catch
try { parseArgs(process.argv); }
catch (err) { if (/requires --watch-count/.test(err.message)) { console.error(err.message); printHelp(2); } else throw err; } Prevention
- In CI templates, always pair --exit-code --watch with a fixed --watch-count.
- For one-shot exit gating, omit --watch entirely.
- Document the rationale (bounded termination) next to the flag.
When it happens
Trigger: Invoking `loop-status.js --exit-code --watch` with no --watch-count. Adding --watch for live monitoring but forgetting that --exit-code needs a bounded run to make sense.
Common situations: CI scripts that want both an exit gate and periodic updates. Operators copying a watch example into an exit-code pipeline without the count.
Related errors
- --write requires a path
- Unknown argument: ${arg}
- Invalid ${flag}: expected a single cache path segment
- Unknown argument: ${arg}
- Missing value for ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/f1dd119887521ee0.
Report an issue: GitHub.