jackwener/OpenCLI · error · ArgumentError
--timeout must be an integer >= 30 seconds
Error message
--timeout must be an integer >= 30 seconds
What it means
parseTimeoutSeconds converts the --timeout value to a number and throws ArgumentError unless it is an integer >= 30. The value drives the overall publish deadline, so non-numeric, fractional, or too-small values are rejected up front.
Source
Thrown at clis/wechat-channels/publish.js:85
try {
stat = fs.statSync(resolved);
} catch {
throw new ArgumentError(`${label}文件不存在: ${resolved}`);
}
if (!stat.isFile()) {
throw new ArgumentError(`${label}路径不是文件: ${resolved}`);
}
const ext = path.extname(resolved).toLowerCase();
if (!allowedExts.has(ext)) {
throw new ArgumentError(`不支持的${label}格式: ${ext}(支持 ${Array.from(allowedExts).join('/')})`);
}
return resolved;
}
function parseTimeoutSeconds(raw) {
const timeout = raw == null || raw === '' ? 600 : Number(raw);
if (!Number.isInteger(timeout) || timeout < 30) {
throw new ArgumentError('--timeout must be an integer >= 30 seconds');
}
return timeout;
}
function parseScheduleDate(raw) {
if (!raw) return null;
const dt = typeof raw === 'number'
? new Date(raw < 1e12 ? raw * 1000 : raw)
: new Date(String(raw));
if (Number.isNaN(dt.getTime())) {
throw new ArgumentError(`无法解析定时时间: ${raw}`);
}
if (dt.getTime() <= Date.now()) {
throw new ArgumentError('定时时间必须晚于当前时间');
}
return dt;
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a plain integer number of seconds >= 30, e.g. --timeout 600.
- Convert minutes to seconds yourself: 10m -> 600.
- Omit --timeout entirely to use the default of 600 seconds.
Example fix
// before node publish.js --video v.mp4 --timeout 10m // after node publish.js --video v.mp4 --timeout 600
Defensive patterns
Strategy: validation
Validate before calling
const t = Number(timeoutRaw);
if (!Number.isInteger(t) || t < 30) {
throw new Error('--timeout must be an integer >= 30 seconds');
} Type guard
function isValidTimeout(v) {
return Number.isInteger(v) && v >= 30;
} Try / catch
try {
await publish({ timeout: timeoutRaw });
} catch (e) {
if (e.message.includes('--timeout')) {
console.error('Use plain seconds, e.g. --timeout 600');
}
throw e;
} Prevention
- Pass plain integer seconds; convert '10m' to 600 yourself.
- Omit --timeout to use the 600s default.
- Document timeout in wrapper scripts as seconds only.
When it happens
Trigger: Passing --timeout abc, --timeout 25, --timeout 90.5, or an empty-but-nondefault value that Number() coerces to NaN.
Common situations: Typos like '10m' or '1h' (not parsed), copying a timeout with a unit suffix, setting a very short timeout to 'test quickly'.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- --timeout must be a positive integer (seconds)
- ocr-wait-seconds must be a non-negative integer: ${raw}
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/72f9a2f1a262a877.
Report an issue: GitHub.