jackwener/OpenCLI · error · ArgumentError
定时时间必须晚于当前时间
Error message
定时时间必须晚于当前时间
What it means
After successfully parsing the schedule date, parseScheduleDate throws ArgumentError if the time is not strictly after Date.now(). Publishing schedules in the past are rejected by the workflow, so the check fails fast before any UI automation runs.
Source
Thrown at clis/wechat-channels/publish.js:99
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;
}
function parseBooleanFlag(raw) {
return raw === true || raw === 'true' || raw === '1' || raw === 1;
}
function remainingMs(deadline, label) {
const left = deadline - Date.now();
if (left <= 0) {
throw new CommandExecutionError(`${label}超时,请增加 --timeout 后重试`);
}
return left;
}
function submitSucceeded({ isDraft, finalUrl, successMsg }) {
const msg = String(successMsg || '');View on GitHub (pinned to 49907e53dc)
Solutions
- Choose a schedule time at least a few minutes in the future.
- Verify timezone handling — prefer ISO strings with explicit offsets like +08:00.
- Regenerate the timestamp at invocation time rather than reading it from cached config.
Example fix
// before node publish.js --schedule 1756000000000 // past timestamp // after node publish.js --schedule $(($(date +%s) + 3600))000 // now + 1h, in ms
Defensive patterns
Strategy: validation
Validate before calling
const dt = new Date(scheduleRaw);
if (dt.getTime() <= Date.now()) {
throw new Error('Schedule time must be in the future');
} Type guard
function isFutureDate(v) {
return new Date(v).getTime() > Date.now();
} Try / catch
try {
await publish({ schedule: scheduleRaw });
} catch (e) {
if (/定时时间必须晚于当前时间/.test(e.message)) {
console.error('Regenerate the timestamp; the cached one is in the past');
}
throw e;
} Prevention
- Generate the schedule timestamp at invocation time, never from cached config.
- Add a buffer of a few minutes over 'now'.
- Double-check timezone offsets so intended local times do not land in the past.
When it happens
Trigger: Passing a timestamp that is already in the past; computing the value with seconds when the code compared against a shifted clock; a long-running script where the schedule time elapsed between computing it and invoking the command.
Common situations: Reusing an old schedule timestamp from config; forgetting timezone offset so local time is interpreted as UTC (or vice versa) and lands in the past; re-running a command hours later with the same arguments.
Related errors
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
- --from and --to must differ; both resolved to ${fromStation.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/aedfd6a380727fdc.
Report an issue: GitHub.