xpzouying/xiaohongshu-mcp · warning
评论区过大,%s 内未找到目标评论 (commentID: %s, userID: %s)
Error message
评论区过大,%s 内未找到目标评论 (commentID: %s, userID: %s)
What it means
findCommentElement 的超时收口:滚动搜索达到 maxSearchDuration 时限仍未命中目标评论,但评论区条目数仍在增长(过大),说明评论太多在时限内翻不完,而非评论不存在。
Source
Thrown at xiaohongshu/comment_feed.go:210
// findCommentElement 滚动查找指定评论:优先按 commentID 命中,否则按 userID 匹配。
// 二级评论折叠在「展开 N 条回复」后面,未展开时不在 DOM 里,因此查找过程中要展开。
func findCommentElement(ctx context.Context, page *rod.Page, commentID, userID string) (*rod.Element, error) {
logrus.Infof("开始查找评论 - commentID: %s, userID: %s", commentID, userID)
scrollToCommentsArea(page)
humanize.Delay(ctx, humanize.BetweenScroll)
lastCommentCount := 0
stagnantChecks := 0
expandRounds := 0
deadline := time.Now().Add(maxSearchDuration)
// attempt 只数下滚,展开不计入,由 deadline 收口。
for attempt := 0; attempt < maxSearchScrolls; {
if time.Now().After(deadline) {
logrus.Warnf("查找超过 %s,停止", maxSearchDuration)
return nil, fmt.Errorf("评论区过大,%s 内未找到目标评论 (commentID: %s, userID: %s)",
maxSearchDuration, commentID, userID)
}
// 1. 先查已渲染的评论
if el := lookupComment(page, commentID, userID); el != nil {
logrus.Infof("✓ 找到目标评论(下滚 %d 次)", attempt)
return el, nil
}
// 2. 展开视野里的楼中楼后再查一次
if expandRounds < maxExpandRounds {
if expanded := expandNearbyReplies(ctx, page); expanded > 0 {
expandRounds++
humanize.Delay(ctx, humanize.Reading)
if el := lookupComment(page, commentID, userID); el != nil {
logrus.Infof("✓ 展开楼中楼后找到目标评论(下滚 %d 次)", attempt)
return el, nilView on GitHub (pinned to 332d196854)
Solutions
- 确认目标 commentID/userID 对应的评论仍存在(在浏览器手动打开该 feed 查找)
- 调大 maxSearchDuration 以适配超长评论区
- 评论很旧/很深时考虑放弃或改用其他触达路径,而非长时间滚动
- 检查网络状况,弱网下懒加载跟不上滚动会耗尽时间预算
Example fix
// 调用方处理(库内 deadline 为固定预算)
err := action.ReplyToComment(ctx, feedID, token, commentID, userID, content)
if err != nil && strings.Contains(err.Error(), "评论区过大") {
log.Warnf("评论 %s 在深评论区未找到,安排低峰重试", commentID)
scheduleRetryWithBackoff(feedID, commentID, userID, content)
return
} Defensive patterns
Strategy: retry
Validate before calling
if commentID == "" && userID == "" {
return errors.New("commentID 与 userID 均为空,无法定位目标评论")
} Try / catch
err := action.ReplyToComment(ctx, feedID, token, commentID, userID, content)
if err != nil {
if strings.Contains(err.Error(), "评论区过大") {
// 时间预算耗尽:安排一次低峰重试后放弃
scheduleRetryWithBackoff(feedID, commentID, userID, content)
return
}
return err
} Prevention
- 优先对近期/靠前的评论回复,避免在数千条评论的帖子里翻找旧评论
- 回复前确认 commentID 来自较新的抓取数据,减少评论已被删除的概率
- 对热门帖子设置预期:深评论区查找天然耗时,做好重试/放弃策略
- 保持网络稳定,弱网会显著降低滚动查找成功率
When it happens
Trigger: 调用 ReplyToComment 时目标评论在很长的评论区深处,滚动查找超过 maxSearchDuration 仍未出现:评论数极多、懒加载慢、或目标评论实际已被删除/不可见。
Common situations: 给热门帖子(数千条评论)的旧评论回复;commentID 对应的评论已被作者删除或被平台隐藏;弱网下懒加载跟不上滚动节奏,白白耗尽时间预算。
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/40939cbc72497d8a.
Report an issue: GitHub.