{"record":{"id":"0d0b62e86618841a","repo":"jackwener/OpenCLI","slug":"reason-tmp-wechat-channels-schedu","errorCode":null,"errorMessage":"定时设置失败 (${reason})，截图: /tmp/wechat-channels_schedule_debug.png","messagePattern":"定时设置失败 \\((.+?)\\)，截图: /tmp/wechat-channels_schedule_debug\\.png","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/wechat-channels/publish.js","lineNumber":506,"sourceCode":"        return false;\n      }\n      var hourOk = pickFromColumn(timeDl.querySelector('ol.weui-desktop-picker__time__hour'), pad(TH));\n      if (!hourOk) return { ok: false, reason: 'hour-disabled', hour: TH };\n      await sleep(300);\n      var minOk = pickFromColumn(timeDl.querySelector('ol.weui-desktop-picker__time__minute'), pad(TMin));\n      if (!minOk) return { ok: false, reason: 'minute-disabled', minute: TMin };\n      await sleep(300);\n\n      // 6. Read back the display input to confirm the value landed.\n      var inp = deepQuery('input[placeholder*=\"发表时间\"]');\n      return { ok: true, value: inp ? inp.value : null };\n    })(${targetYear}, ${targetMonth}, ${targetDay}, ${targetHour}, ${targetMin})\n  `);\n\n  if (!result?.ok) {\n    await page.screenshot({ path: '/tmp/wechat-channels_schedule_debug.png' });\n    const reason = result?.reason ? String(result.reason) : 'empty picker result';\n    throw new CommandExecutionError(\n      `定时设置失败 (${reason})，截图: /tmp/wechat-channels_schedule_debug.png`,\n    );\n  }\n\n  const expected = `${targetYear}-${pad(targetMonth)}-${pad(targetDay)} ${pad(targetHour)}:${pad(targetMin)}`;\n  if (!String(result.value || '').includes(expected)) {\n    throw new CommandExecutionError(`定时设置未验证成功: expected=${expected} actual=${result.value || ''}`);\n  }\n  process.stderr.write(`  定时设置完成: ${result.value || expected}\\n`);\n}\n\n// ── Helper: click publish or draft button ────────────────────────────────────\nasync function clickPublish(page, isDraft) {\n  const labels = isDraft\n    ? ['存草稿', '保存草稿', '草稿']\n    : ['发表', '发布'];\n\n  const clicked = await evalPage(page, `","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wechat-channels/publish.js#L488-L524","documentation":"setScheduleTime in clis/wechat-channels/publish.js throws CommandExecutionError when an in-page picker script fails to set the scheduled publish time on the WeChat Channels upload page. The page script returns {ok:false} (with an optional reason) whenever the date/time fields could not be filled or confirmed. A debug screenshot is saved to /tmp/wechat-channels_schedule_debug.png before throwing.","triggerScenarios":"The page.evaluate(...) result is falsy, has ok:false, or lacks a reason; e.g. the schedule picker DOM did not match selectors, the 'scheduled publish' radio/switch was not enabled, or picker values were rejected.","commonSituations":"WeChat Channels frontend markup changed so the picker selectors no longer match; user scheduled a time in the past or outside the allowed window; page loaded slowly so picker elements were absent; a previous form error disabled scheduling.","solutions":["Open /tmp/wechat-channels_schedule_debug.png to see the actual page state at failure","Verify the scheduled time is in the future and within WeChat's allowed scheduling window","Retry with a longer page wait or re-run, as transient load issues can leave picker elements missing","Update the picker selectors in setScheduleTime to match current weixin.qq.com DOM","Fall back to immediate publish (--draft or no schedule) if scheduling is not essential"],"exampleFix":"// before\nawait page.wait({ time: 1 });\nconst result = await page.evaluate(`(function(){ ...pick date... })()`);\n// after\nawait page.waitForSelector('.schedule-picker, [class*=timer]', { visible: true });\nconst result = await page.evaluate(`(function(){ ...pick date... })()`);","handlingStrategy":"validation","validationCode":"if (!(schedTime instanceof Date) || schedTime.getTime() <= Date.now() + 10 * 60 * 1000) {\n  throw new Error('Schedule time must be in the future (WeChat requires > ~10 min ahead)');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await setScheduleTime(page, y, mo, d, h, mi);\n} catch (e) {\n  console.error('Schedule failed, see /tmp/wechat-channels_schedule_debug.png:', e.message);\n  // fallback: publish immediately or abort\n}","preventionTips":["Always pass a future time inside WeChat's scheduling window","Check the debug screenshot after any failure","Keep picker selectors updated with site markup changes","Prefer --manual first run to inspect the schedule UI"],"tags":["wechat-channels","scheduling","browser-automation"],"backgroundTag":"schedule-picker-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}