{"record":{"id":"c0f557ab4608d15a","repo":"jackwener/OpenCLI","slug":"error-c0f557","errorCode":null,"errorMessage":"视频上传失败，请检查文件格式和网络连接","messagePattern":"视频上传失败，请检查文件格式和网络连接","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/wechat-channels/publish.js","lineNumber":307,"sourceCode":"          var hasFileEvidence = fileName && bodyText.indexOf(fileName) >= 0;\n          var hasSuccessText = /上传成功|转码完成|处理完成/.test(bodyText);\n          return { done: !uploading && (!!preview || hasFileEvidence || hasSuccessText), failed: false };\n        })(${JSON.stringify(fileName)})\n      `);\n    } catch (err) {\n      // Bridge may temporarily disconnect when the page re-renders after file is set.\n      // Wait and retry rather than aborting.\n      const msg = err instanceof Error ? err.message : String(err);\n      if (msg.includes('ECONNRESET') || msg.includes('fetch failed')) {\n        process.stderr.write(`  [retry] bridge reconnecting after page re-render (${i + 1}/${maxAttempts})...\\n`);\n        await page.wait({ time: pollMs / 1000 });\n        continue;\n      }\n      throw err;\n    }\n\n    if (done?.failed) {\n      throw new CommandExecutionError('视频上传失败，请检查文件格式和网络连接');\n    }\n    if (done?.done) return;\n\n    await page.wait({ time: pollMs / 1000 });\n  }\n\n  throw new CommandExecutionError(`视频上传/转码超时（${Math.ceil(maxMs / 1000)}秒），请检查网络或稍后重试`);\n}\n\n// ── Helper: fill text field (with shadow DOM traversal) ─────────────────────\nasync function fillField(page, selectors, text, fieldName) {\n  const result = await evalPage(page, `\n    (function(selectors, text) {\n      ${DEEP_QUERY_FN}\n\n      var el = null;\n      var foundSel = null;\n      for (var i = 0; i < selectors.length; i++) {","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wechat-channels/publish.js#L289-L325","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Check network stability and retry on a reliable connection.","Confirm the Chrome session is still logged in and re-authenticate if needed.","Try a smaller file to rule out server-side size limits."],"exampleFix":"// before\nnode publish.js --video hevc-recording.mp4\n// after\nffmpeg -i hevc-recording.mp4 -c:v libx264 -pix_fmt yuv420p -c:a aac hevc-recording-h264.mp4\nnode publish.js --video hevc-recording-h264.mp4","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await publish({ videoPath });\n} catch (e) {\n  if (/视频上传失败/.test(e.message)) {\n    // re-encode to H.264/AAC MP4, verify network, then retry\n    await reencodeToH264(videoPath);\n    return publish({ videoPath: reencodedPath });\n  }\n  throw e;\n}","preventionTips":["Encode uploads as H.264/AAC MP4 with yuv420p pixel format.","Verify the file plays locally before uploading.","Avoid uploading over unstable Wi-Fi/VPN connections."],"tags":["upload","network","video-format"],"backgroundTag":"upload-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}