xpzouying/xiaohongshu-mcp · error

等待发布按钮可点击超时

Error message

等待发布按钮可点击超时

What it means

waitForPublishButtonClickable polls the publish button (custom element `xhs-publish-btn` or fallback selector) until it is enabled, recording the last reason it was disabled. If the deadline expires it throws this generic timeout, or — if a disable reason was captured (e.g. '上传中', '请填写正文') — the more specific wrapped variant with that reason appended.

Source

Thrown at xiaohongshu/publish.go:478

		btn, disabledReason, err := findPublishButton(page)
		if err != nil {
			slog.Warn("查找发布按钮失败,继续等待", "error", err)
			time.Sleep(interval)
			continue
		}
		if btn != nil && disabledReason == "" {
			return btn, nil
		}
		if disabledReason != "" {
			lastDisabledReason = disabledReason
		}
		time.Sleep(interval)
	}

	if lastDisabledReason != "" {
		return nil, errors.Errorf("等待发布按钮可点击超时: %s", lastDisabledReason)
	}
	return nil, errors.New("等待发布按钮可点击超时")
}

func findPublishButton(page *rod.Page) (*publishButton, string, error) {
	widgets, err := page.Elements("xhs-publish-btn")
	if err != nil {
		return nil, "", errors.Wrap(err, "查找新版发布按钮失败")
	}

	for _, widget := range widgets {
		if !isElementVisible(widget) {
			continue
		}

		isPublish, err := widget.Attribute("is-publish")
		if err != nil {
			return nil, "", errors.Wrap(err, "读取新版发布按钮 is-publish 属性失败")
		}
		if isPublish != nil && *isPublish == "false" {

View on GitHub (pinned to 332d196854)

Solutions

  1. Read the wrapped reason (errors.Errorf variant) — it names the disable cause; fill the missing field or wait for uploads to finish
  2. Ensure findContentElement/clickAddProductButton etc. completed so required inputs are filled before waiting
  3. Verify the `xhs-publish-btn` custom element still exists on the current XHS publish page version; update findPublishButton selectors if redesigned
  4. Increase the deadline/interval to accommodate slow media uploads on poor networks

Example fix

// before
return nil, errors.New("等待发布按钮可点击超时")
// after
return nil, errors.Errorf("等待发布按钮可点击超时 (lastDisabledReason=%s)", lastDisabledReason)
Defensive patterns

Strategy: validation

Validate before calling

// 发布前自检:必填项与上传是否完成
if title == "" || description == "" {
	return errors.New("请先填写标题和正文再发布")
}
if !uploadCompleted {
	return errors.New("等待图片/视频上传完成后再发布")
}

Prevention

When it happens

Trigger: clickPublishButton or uploadVideo call it before clicking; the button remains disabled past the deadline because required fields are empty, files are still uploading, or the button selector no longer matches the current XHS page version.

Common situations: Missing or too-short description; images/video still uploading (button disabled with a progress state); XHS A/B redesign moving the button out of the polled selector; very slow uploads exceeding the wait interval budget.

Related errors


AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05). Data as JSON: /api/errors/e1c322ac82935758. Report an issue: GitHub.