jackwener/OpenCLI · error · CommandExecutionError

视频上传失败,请检查文件格式和网络连接

Error message

视频上传失败,请检查文件格式和网络连接

What it means

waitForUploadDone polls the page for upload/transcode status; if the polled state reports failed (done.failed), it throws CommandExecutionError stating the video upload failed and suggesting format/network checks. This reflects the WeChat page itself marking the upload as failed, not a local timeout.

Source

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

          var hasFileEvidence = fileName && bodyText.indexOf(fileName) >= 0;
          var hasSuccessText = /上传成功|转码完成|处理完成/.test(bodyText);
          return { done: !uploading && (!!preview || hasFileEvidence || hasSuccessText), failed: false };
        })(${JSON.stringify(fileName)})
      `);
    } catch (err) {
      // Bridge may temporarily disconnect when the page re-renders after file is set.
      // Wait and retry rather than aborting.
      const msg = err instanceof Error ? err.message : String(err);
      if (msg.includes('ECONNRESET') || msg.includes('fetch failed')) {
        process.stderr.write(`  [retry] bridge reconnecting after page re-render (${i + 1}/${maxAttempts})...\n`);
        await page.wait({ time: pollMs / 1000 });
        continue;
      }
      throw err;
    }

    if (done?.failed) {
      throw new CommandExecutionError('视频上传失败,请检查文件格式和网络连接');
    }
    if (done?.done) return;

    await page.wait({ time: pollMs / 1000 });
  }

  throw new CommandExecutionError(`视频上传/转码超时(${Math.ceil(maxMs / 1000)}秒),请检查网络或稍后重试`);
}

// ── Helper: fill text field (with shadow DOM traversal) ─────────────────────
async function fillField(page, selectors, text, fieldName) {
  const result = await evalPage(page, `
    (function(selectors, text) {
      ${DEEP_QUERY_FN}

      var el = null;
      var foundSel = null;
      for (var i = 0; i < selectors.length; i++) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the file plays locally and re-encode to H.264/AAC MP4: ffmpeg -i in.mp4 -c:v libx264 -c:a aac out.mp4.
  2. Check network stability and retry on a reliable connection.
  3. Confirm the Chrome session is still logged in and re-authenticate if needed.
  4. Try a smaller file to rule out server-side size limits.

Example fix

// before
node publish.js --video hevc-recording.mp4
// after
ffmpeg -i hevc-recording.mp4 -c:v libx264 -pix_fmt yuv420p -c:a aac hevc-recording-h264.mp4
node publish.js --video hevc-recording-h264.mp4
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try {
  await publish({ videoPath });
} catch (e) {
  if (/视频上传失败/.test(e.message)) {
    // re-encode to H.264/AAC MP4, verify network, then retry
    await reencodeToH264(videoPath);
    return publish({ videoPath: reencodedPath });
  }
  throw e;
}

Prevention

When it happens

Trigger: The creator page shows an upload failure state: corrupted/unplayable file, codec unsupported by WeChat despite an allowed extension, network interruption mid-upload, or session/auth expiring during upload.

Common situations: Renamed files whose container does not match the extension; videos with exotic codecs (e.g. HEVC in .mp4); flaky Wi-Fi or VPN dropping the connection; oversized files hitting server limits.

Related errors


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