jackwener/OpenCLI · error · CommandExecutionError

定时设置失败 (${reason}),截图: /tmp/wechat-channels_schedule_debug.p

Error message

定时设置失败 (${reason}),截图: /tmp/wechat-channels_schedule_debug.png

What it means

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.

Source

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

        return false;
      }
      var hourOk = pickFromColumn(timeDl.querySelector('ol.weui-desktop-picker__time__hour'), pad(TH));
      if (!hourOk) return { ok: false, reason: 'hour-disabled', hour: TH };
      await sleep(300);
      var minOk = pickFromColumn(timeDl.querySelector('ol.weui-desktop-picker__time__minute'), pad(TMin));
      if (!minOk) return { ok: false, reason: 'minute-disabled', minute: TMin };
      await sleep(300);

      // 6. Read back the display input to confirm the value landed.
      var inp = deepQuery('input[placeholder*="发表时间"]');
      return { ok: true, value: inp ? inp.value : null };
    })(${targetYear}, ${targetMonth}, ${targetDay}, ${targetHour}, ${targetMin})
  `);

  if (!result?.ok) {
    await page.screenshot({ path: '/tmp/wechat-channels_schedule_debug.png' });
    const reason = result?.reason ? String(result.reason) : 'empty picker result';
    throw new CommandExecutionError(
      `定时设置失败 (${reason}),截图: /tmp/wechat-channels_schedule_debug.png`,
    );
  }

  const expected = `${targetYear}-${pad(targetMonth)}-${pad(targetDay)} ${pad(targetHour)}:${pad(targetMin)}`;
  if (!String(result.value || '').includes(expected)) {
    throw new CommandExecutionError(`定时设置未验证成功: expected=${expected} actual=${result.value || ''}`);
  }
  process.stderr.write(`  定时设置完成: ${result.value || expected}\n`);
}

// ── Helper: click publish or draft button ────────────────────────────────────
async function clickPublish(page, isDraft) {
  const labels = isDraft
    ? ['存草稿', '保存草稿', '草稿']
    : ['发表', '发布'];

  const clicked = await evalPage(page, `

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open /tmp/wechat-channels_schedule_debug.png to see the actual page state at failure
  2. Verify the scheduled time is in the future and within WeChat's allowed scheduling window
  3. Retry with a longer page wait or re-run, as transient load issues can leave picker elements missing
  4. Update the picker selectors in setScheduleTime to match current weixin.qq.com DOM
  5. Fall back to immediate publish (--draft or no schedule) if scheduling is not essential

Example fix

// before
await page.wait({ time: 1 });
const result = await page.evaluate(`(function(){ ...pick date... })()`);
// after
await page.waitForSelector('.schedule-picker, [class*=timer]', { visible: true });
const result = await page.evaluate(`(function(){ ...pick date... })()`);
Defensive patterns

Strategy: validation

Validate before calling

if (!(schedTime instanceof Date) || schedTime.getTime() <= Date.now() + 10 * 60 * 1000) {
  throw new Error('Schedule time must be in the future (WeChat requires > ~10 min ahead)');
}

Try / catch

try {
  await setScheduleTime(page, y, mo, d, h, mi);
} catch (e) {
  console.error('Schedule failed, see /tmp/wechat-channels_schedule_debug.png:', e.message);
  // fallback: publish immediately or abort
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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