xpzouying/xiaohongshu-mcp · error
发布未确认成功:点击发布后未跳转离开发布页(可能校验未过或被拦截)
Error message
发布未确认成功:点击发布后未跳转离开发布页(可能校验未过或被拦截)
What it means
waitPublishSuccess polls page.Info() every 500ms until the URL no longer contains /publish/publish, treating navigation away as confirmation that the post was published. If the deadline expires while still on the publish page, it throws this error: the publish click happened but success could not be confirmed — the post may have failed validation, been rate-limited, or blocked by a toast/dialog.
Source
Thrown at xiaohongshu/publish.go:424
return err
}
// 校验发布真的成功:成功后创作平台会跳转离开发布页;未跳转则判定失败,
// 消除"点了发布按钮就算成功"的假阳性。
return waitPublishSuccess(page, 15*time.Second)
}
// waitPublishSuccess 轮询等待发布成功的信号:小红书发布成功后会跳转离开发布表单页
// (URL 不再含 /publish/publish)。超时仍未跳转 → 判定发布失败。
func waitPublishSuccess(page *rod.Page, timeout time.Duration) error {
deadline := time.Now().Add(timeout)
for {
if info, err := page.Info(); err == nil && !strings.Contains(info.URL, "/publish/publish") {
slog.Info("发布成功,已跳转离开发布页", "url", info.URL)
return nil
}
if time.Now().After(deadline) {
return errors.New("发布未确认成功:点击发布后未跳转离开发布页(可能校验未过或被拦截)")
}
time.Sleep(500 * time.Millisecond)
}
}
type publishButton struct {
elem *rod.Element
isWidget bool
}
func clickPublishButton(page *rod.Page) error {
btn, err := waitForPublishButtonClickable(page, 15*time.Second)
if err != nil {
return err
}
if btn.isWidget {
return clickPublishWidget(page, btn.elem)View on GitHub (pinned to 332d196854)
Solutions
- Check the page manually on failure — capture page screenshot/DOM to see the error toast or dialog blocking navigation
- Ensure title/description meet length and content rules; missing description commonly blocks publishing
- Extend the deadline if the network/XHS backend is slow; success may just be delayed
- Detect in-page error toasts (e.g. .toast / error popups) instead of relying only on URL change, and surface their text in the error
- Confirm the publish button click actually landed (waitForPublishButtonClickable succeeded and click reported no error)
Example fix
// before
if time.Now().After(deadline) {
return errors.New("发布未确认成功:...")
}
// after
if time.Now().After(deadline) {
if toast, _ := page.Element(".toast"); toast != nil {
msg, _ := toast.Text()
return errors.Errorf("发布未确认成功: 页面提示 %q", msg)
}
return errors.New("发布未确认成功:点击发布后未跳转离开发布页")
} Defensive patterns
Strategy: try-catch
Try / catch
if err := submitPublish(page); err != nil {
if strings.Contains(err.Error(), "发布未确认成功") {
shot, _ := page.Screenshot(true, nil) // 留证排查:校验未过或被拦截
_ = os.WriteFile("publish-fail.png", shot, 0644)
// 检查标题/正文是否违规或缺失后重试
}
return err
} Prevention
- Ensure all required fields (title, description) are filled and within length limits
- Avoid sensitive/banned words that fail XHS review
- Take a screenshot on failure to see blocking toasts/dialogs
- Allow generous deadline on slow networks
When it happens
Trigger: submitPublish or submitPublishVideo clicked the publish button but the SPA never navigated away within the deadline — e.g. form validation error (missing title/description), a toast like '包含违规内容', a confirmation dialog, or the click actually missed the button.
Common situations: Content rejected by XHS review (sensitive words, watermarked images); missing required fields; new-user rate limits; slow XHS backend exceeding the deadline; XHS changing its publish-success URL pattern.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/718e5e9a46249d2c.
Report an issue: GitHub.