{"record":{"id":"26c0bff816af4ecd","repo":"jackwener/OpenCLI","slug":"label-timeout","errorCode":null,"errorMessage":"${label}超时，请增加 --timeout 后重试","messagePattern":"(.+?)超时，请增加 --timeout 后重试","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/wechat-channels/publish.js","lineNumber":111,"sourceCode":"    ? new Date(raw < 1e12 ? raw * 1000 : raw)\n    : new Date(String(raw));\n  if (Number.isNaN(dt.getTime())) {\n    throw new ArgumentError(`无法解析定时时间: ${raw}`);\n  }\n  if (dt.getTime() <= Date.now()) {\n    throw new ArgumentError('定时时间必须晚于当前时间');\n  }\n  return dt;\n}\n\nfunction parseBooleanFlag(raw) {\n  return raw === true || raw === 'true' || raw === '1' || raw === 1;\n}\n\nfunction remainingMs(deadline, label) {\n  const left = deadline - Date.now();\n  if (left <= 0) {\n    throw new CommandExecutionError(`${label}超时，请增加 --timeout 后重试`);\n  }\n  return left;\n}\n\nfunction submitSucceeded({ isDraft, finalUrl, successMsg }) {\n  const msg = String(successMsg || '');\n  if (isDraft) {\n    return /草稿已保存|暂存成功|保存成功/.test(msg);\n  }\n  if (/已发表|发布成功|发表成功|审核中/.test(msg)) {\n    return true;\n  }\n  const url = String(finalUrl || '');\n  return /\\/platform\\/post\\/list\\b/.test(url);\n}\n\nexport const __test__ = {\n  parseTimeoutSeconds,","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wechat-channels/publish.js#L93-L129","documentation":"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.","triggerScenarios":"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.","commonSituations":"Large video files on slow uplinks; WeChat transcode taking longer than usual; setting --timeout 60 for a multi-minute upload.","solutions":["Re-run with a larger --timeout, e.g. --timeout 1800.","Upload a smaller/lower-bitrate video to shorten upload and transcode time.","Check network throughput; retry when the connection is stable."],"exampleFix":"// before\nnode publish.js --video big-4k.mp4 --timeout 60\n// after\nnode publish.js --video big-4k.mp4 --timeout 1800","handlingStrategy":"retry","validationCode":"const fileSize = require('fs').statSync(videoPath).size;\nconst estSeconds = (fileSize / (5 * 1024 * 1024)) * 2; // ~5 Mbps up, 2x safety\nif (estSeconds > timeoutSeconds) {\n  throw new Error(`--timeout ${timeoutSeconds}s likely too small for ${fileSize} bytes`);\n}","typeGuard":"null","tryCatchPattern":"try {\n  await publish({ videoPath, timeout });\n} catch (e) {\n  if (/超时，请增加 --timeout/.test(e.message)) {\n    return publish({ videoPath, timeout: timeout * 2 });\n  }\n  throw e;\n}","preventionTips":["Size --timeout to your upload bandwidth and file size, with 2-3x headroom.","Prefer stable wired connections for large uploads.","Compress videos before publishing to shorten the flow."],"tags":["timeout","cli","network"],"backgroundTag":"command-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}