xpzouying/xiaohongshu-mcp · error
第%d张图片上传超时(60s),请检查网络连接和图片大小
Error message
第%d张图片上传超时(60s),请检查网络连接和图片大小
What it means
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张图片上传超时'.
Source
Thrown at xiaohongshu/publish.go:341
if err != nil {
time.Sleep(checkInterval)
continue
}
currentCount := len(uploadedImages)
if currentCount != lastLogCount {
slog.Info("等待图片上传", "current", currentCount, "expected", expectedCount)
lastLogCount = currentCount
}
if currentCount >= expectedCount {
slog.Info("图片上传完成", "count", currentCount)
return nil
}
time.Sleep(checkInterval)
}
return errors.Errorf("第%d张图片上传超时(60s),请检查网络连接和图片大小", expectedCount)
}
func submitPublish(ctx context.Context, page *rod.Page, title, content string, tags []string, scheduleTime *time.Time, isOriginal bool, visibility string, products []string) error {
titleElem, err := page.Element("div.d-input input")
if err != nil {
return errors.Wrap(err, "查找标题输入框失败")
}
if err := humanize.Type(ctx, titleElem, title); err != nil {
return errors.Wrap(err, "输入标题失败")
}
humanize.Delay(ctx, humanize.AfterType)
if err := checkTitleMaxLength(page); err != nil {
return err
}
slog.Info("检查标题长度:通过")
humanize.Delay(ctx, humanize.AfterType)View on GitHub (pinned to 332d196854)
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
Example fix
// before maxWaitTime := 60 * time.Second // after maxWaitTime := 180 * time.Second // 慢网络/大图场景调大等待窗口
Defensive patterns
Strategy: retry
Try / catch
var err error
for attempt := 0; attempt < 2; attempt++ {
err = bot.Publish(ctx, post, images)
if err == nil || !strings.Contains(err.Error(), "上传超时") { break }
time.Sleep(5 * time.Second)
} Prevention
- 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
When it happens
Trigger: waitForUploadComplete(page, expectedCount) exhausting maxWaitTime=60s because len(.img-preview-area .pr) < expectedCount, thrown at xiaohongshu/publish.go:341.
Common situations: 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.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/baa5778786937f79.
Report an issue: GitHub.