jackwener/OpenCLI · error · CommandExecutionError

${label}超时,请增加 --timeout 后重试

Error message

${label}超时,请增加 --timeout 后重试

What it means

remainingMs computes time left before the overall publish deadline; when the deadline has passed it throws CommandExecutionError telling the user to raise --timeout and retry. This is the guard ensuring no automation step continues after the user-specified time budget is exhausted.

Source

Thrown at clis/wechat-channels/publish.js:111

    ? 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 || '');
  if (isDraft) {
    return /草稿已保存|暂存成功|保存成功/.test(msg);
  }
  if (/已发表|发布成功|发表成功|审核中/.test(msg)) {
    return true;
  }
  const url = String(finalUrl || '');
  return /\/platform\/post\/list\b/.test(url);
}

export const __test__ = {
  parseTimeoutSeconds,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run with a larger --timeout, e.g. --timeout 1800.
  2. Upload a smaller/lower-bitrate video to shorten upload and transcode time.
  3. Check network throughput; retry when the connection is stable.

Example fix

// before
node publish.js --video big-4k.mp4 --timeout 60
// after
node publish.js --video big-4k.mp4 --timeout 1800
Defensive patterns

Strategy: retry

Validate before calling

const fileSize = require('fs').statSync(videoPath).size;
const estSeconds = (fileSize / (5 * 1024 * 1024)) * 2; // ~5 Mbps up, 2x safety
if (estSeconds > timeoutSeconds) {
  throw new Error(`--timeout ${timeoutSeconds}s likely too small for ${fileSize} bytes`);
}

Type guard

null

Try / catch

try {
  await publish({ videoPath, timeout });
} catch (e) {
  if (/超时,请增加 --timeout/.test(e.message)) {
    return publish({ videoPath, timeout: timeout * 2 });
  }
  throw e;
}

Prevention

When it happens

Trigger: The total publish flow (navigation, upload, transcode, form filling) exceeds the --timeout value; the deadline elapses while waiting between steps and the next remainingMs call finds left <= 0.

Common situations: Large video files on slow uplinks; WeChat transcode taking longer than usual; setting --timeout 60 for a multi-minute upload.

Understand the failure class

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/26c0bff816af4ecd. Report an issue: GitHub.