{"record":{"id":"baa5778786937f79","repo":"xpzouying/xiaohongshu-mcp","slug":"d-60s","errorCode":null,"errorMessage":"第%d张图片上传超时(60s)，请检查网络连接和图片大小","messagePattern":"第(.+?)张图片上传超时\\(60s\\)，请检查网络连接和图片大小","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":341,"sourceCode":"\t\tif err != nil {\n\t\t\ttime.Sleep(checkInterval)\n\t\t\tcontinue\n\t\t}\n\n\t\tcurrentCount := len(uploadedImages)\n\t\tif currentCount != lastLogCount {\n\t\t\tslog.Info(\"等待图片上传\", \"current\", currentCount, \"expected\", expectedCount)\n\t\t\tlastLogCount = currentCount\n\t\t}\n\t\tif currentCount >= expectedCount {\n\t\t\tslog.Info(\"图片上传完成\", \"count\", currentCount)\n\t\t\treturn nil\n\t\t}\n\n\t\ttime.Sleep(checkInterval)\n\t}\n\n\treturn errors.Errorf(\"第%d张图片上传超时(60s)，请检查网络连接和图片大小\", expectedCount)\n}\n\nfunc submitPublish(ctx context.Context, page *rod.Page, title, content string, tags []string, scheduleTime *time.Time, isOriginal bool, visibility string, products []string) error {\n\ttitleElem, err := page.Element(\"div.d-input input\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"查找标题输入框失败\")\n\t}\n\tif err := humanize.Type(ctx, titleElem, title); err != nil {\n\t\treturn errors.Wrap(err, \"输入标题失败\")\n\t}\n\n\thumanize.Delay(ctx, humanize.AfterType)\n\tif err := checkTitleMaxLength(page); err != nil {\n\t\treturn err\n\t}\n\tslog.Info(\"检查标题长度：通过\")\n\n\thumanize.Delay(ctx, humanize.AfterType)","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L323-L359","documentation":"Root-cause error from waitForUploadComplete: the poll loop checks page.Elements(\".img-preview-area .pr\") every 500ms for at most 60 seconds. When the count of preview thumbnails never reaches expectedCount, it fails with a message telling the developer to check network connection and image size. It is normally seen wrapped by the caller uploadImages as '第%d张图片上传超时'.","triggerScenarios":"waitForUploadComplete(page, expectedCount) exhausting maxWaitTime=60s because len(.img-preview-area .pr) < expectedCount, thrown at xiaohongshu/publish.go:341.","commonSituations":"Uploading large images on slow connections; Xiaohongshu front-end rejecting an image silently; site UI update renaming the preview-area CSS classes; browser tab crashed or CDP connection stalled so Elements() keeps erroring.","solutions":["Verify network upload speed; test the same upload manually in a browser","Reduce image size/format (JPEG/WebP, a few MB max)","Reproduce manually on the creator site to see if the upload shows an error toast (format/quota rejection)","Check whether the .img-preview-area .pr selector still matches after a Xiaohongshu site update and update it","Raise maxWaitTime (60s) or make it configurable for slow networks"],"exampleFix":"// before\nmaxWaitTime := 60 * time.Second\n// after\nmaxWaitTime := 180 * time.Second // 慢网络/大图场景调大等待窗口","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var err error\nfor attempt := 0; attempt < 2; attempt++ {\n    err = bot.Publish(ctx, post, images)\n    if err == nil || !strings.Contains(err.Error(), \"上传超时\") { break }\n    time.Sleep(5 * time.Second)\n}","preventionTips":["Compress large images before upload","Retry transient timeouts on a stable connection","Watch for Xiaohongshu DOM changes affecting .img-preview-area .pr","Consider raising the 60s window for slow networks"],"tags":["upload","timeout","dom-selector","network"],"backgroundTag":"upload-timeout","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}