affaan-m/ECC · error · Error
--watch needs a positive seconds value
Error message
--watch needs a positive seconds value
What it means
Thrown by proximity-tick's parseArgs when `--watch` is given a value that is not a positive integer. The watch loop re-scans agent proximity on a fixed cadence, so a zero/negative/non-integer interval is meaningless and rejected up front. `Number.parseInt` plus `Number.isInteger` and `> 0` is the gate.
Source
Thrown at scripts/proximity-tick.js:31
* Messages are internal ECC agent-to-agent coordination (the ecc2 `messages`
* table) — not any external channel.
*/
const { resolveControlPaneConfig, buildControlPaneSnapshot } = require('./lib/control-pane/state');
const { createProximityDispatcher, runProximityTick } = require('./lib/control-pane/proximity');
const { createEccMessageSink } = require('./lib/control-pane/message-sink');
function parseArgs(argv) {
const args = argv.slice(2);
const parsed = { watchSec: 0, dryRun: false, json: false, help: false, dbPath: null, stateDbPath: null };
for (let i = 0; i < args.length; i += 1) {
const a = args[i];
if (a === '--help' || a === '-h') parsed.help = true;
else if (a === '--dry-run') parsed.dryRun = true;
else if (a === '--json') parsed.json = true;
else if (a === '--watch') {
const v = Number.parseInt(args[i + 1], 10);
if (!Number.isInteger(v) || v <= 0) throw new Error('--watch needs a positive seconds value');
parsed.watchSec = v;
i += 1;
} else if (a === '--db') {
parsed.dbPath = args[i + 1];
i += 1;
} else if (a === '--state-db') {
parsed.stateDbPath = args[i + 1];
i += 1;
} else {
throw new Error(`Unknown argument: ${a}`);
}
}
return parsed;
}
function showHelp() {
console.log(
[View on GitHub (pinned to 01e15490f0)
Solutions
- Pass a positive whole second count: `--watch 30`.
- For a one-shot run, omit --watch entirely (watchSec defaults to 0, meaning no loop).
- Validate env-supplied cadence: integer > 0, else fall back to a sensible default.
Example fix
# before node scripts/proximity-tick.js --watch 0 # after — one shot (no flag) node scripts/proximity-tick.js # or — loop every 30s node scripts/proximity-tick.js --watch 30
Defensive patterns
Strategy: validation
Validate before calling
function parseWatchSeconds(raw) {
const v = Number.parseInt(raw, 10);
if (!Number.isInteger(v) || v <= 0) {
throw new Error('--watch needs a positive seconds value');
}
return v;
} Type guard
function isPositiveIntSeconds(value) {
return typeof value === 'string' && /^[1-9]\d*$/.test(value.trim());
} Try / catch
try {
parseArgs(process.argv);
} catch (err) {
if (err.message === '--watch needs a positive seconds value') {
console.error('Pass a positive whole-second count, e.g. --watch 30. Omit --watch for a one-shot run.');
process.exit(2);
}
throw err;
} Prevention
- Omit --watch for a one-shot scan; do not pass --watch 0 to disable.
- Pass a positive integer (>= 1) of seconds.
- Validate env-derived cadence before forwarding.
When it happens
Trigger: `--watch 0`, `--watch -5`, `--watch 1.5`, `--watch abc`, `--watch` with no following token (parseInt → NaN), or an env-derived cadence that came through empty.
Common situations: User sets `--watch 0` thinking it disables watch (it doesn't — omit the flag for a one-shot); shell variable for seconds expanded to empty; decimal seconds intended but only ints accepted.
Related errors
- Unknown argument: ${a}
- Unknown argument: ${arg}
- Unknown argument: ${arg}
- --timeout-ms must be a positive number
- Invalid format: ${parsed.format}. Use text or json.
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/f7768eed5f8f8dce.
Report an issue: GitHub.