xpzouying/xiaohongshu-mcp · warning

查找新版发布按钮失败

Error message

查找新版发布按钮失败

What it means

findPublishButton wraps failures from page.Elements("xhs-publish-btn") with this message when querying the new-style custom publish button widget errors at the browser level. In waitForPublishButtonClickable this is logged as a warning and the loop keeps waiting rather than aborting immediately.

Source

Thrown at xiaohongshu/publish.go:484

		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" {
			continue
		}

		submitDisabled, err := widget.Attribute("submit-disabled")
		if err != nil {
			return nil, "", errors.Wrap(err, "读取新版发布按钮 submit-disabled 属性失败")

View on GitHub (pinned to 332d196854)

Solutions

  1. Usually transient — the polling loop retries automatically; just retry the whole publish if it surfaces
  2. Ensure the page is not navigating while publish runs
  3. Check the browser process is healthy and the tab is open
  4. Update rod/library if execution-context errors recur after SPA updates
Defensive patterns

Strategy: retry

Try / catch

err := xhs.Publish(...)
if err != nil && strings.Contains(err.Error(), "查找新版发布按钮失败") {
    time.Sleep(time.Second)
    err = xhs.Publish(...) // 通常是瞬时错误,重试即可
}

Prevention

When it happens

Trigger: The CDP/browser query for the custom element fails: page crashed, navigation in progress, or the execution context was destroyed while the SPA re-rendered.

Common situations: Page navigating/reloading during the query; browser tab closed by timeout; rod context cancelled mid-request.

Related errors


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