lyswhut/lx-music-desktop · error · Error

获取回复评论失败

Error message

获取回复评论失败

What it means

Thrown by Migu's getReplyComment when the reply-thread endpoint at https://app.c.nf.migu.cn/MIGUM3.0/user/comment/stack/{replyId}/v1.0 returns non-200 or body.code !== '000000'. Reads body.data.replyTotalCount and body.data.mainCommentItem.replyComments. Critically, this method reuses _requestObj2 (same field as getHotComment), so calling getReplyComment cancels any in-flight getHotComment and vice versa — a shared-request-object bug.

Source

Thrown at src/renderer/utils/musicSdk/mg/comment.js:68

    })
    const { body, statusCode } = await _requestObj2.promise
    // console.log(body)
    if (statusCode != 200 || body.code !== '000000') throw new Error('获取热门评论失败')
    const total = parseInt(body.data.cfgHotCount)
    return { source: 'mg', comments: this.filterComment(body.data.hotComments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
  },
  async getReplyComment(musicInfo, replyId, page = 1, limit = 10) {
    if (this._requestObj2) this._requestObj2.cancelHttp()

    // const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listCommentsById?commentId=${replyId}&pageSize=${limit}&pageNo=${page}`, {
    const _requestObj2 = httpFetch(`https://app.c.nf.migu.cn/MIGUM3.0/user/comment/stack/${replyId}/v1.0?pageSize=${limit}&queryType=2&resourceId=${musicInfo.songId}&resourceType=2&start=${(page - 1) * limit}`, {
      headers: {
        'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
      },
    })
    const { body, statusCode } = await _requestObj2.promise
    // console.log(body)
    if (statusCode != 200 || body.code !== '000000') throw new Error('获取回复评论失败')
    const total = parseInt(body.data.replyTotalCount)
    return { source: 'mg', comments: this.filterComment(body.data.mainCommentItem.replyComments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
  },
  filterComment(rawList) {
    return rawList.map(item => ({
      id: item.commentId,
      text: item.commentInfo,
      time: item.commentTime,
      timeStr: dateFormat2(new Date(item.commentTime).getTime()),
      userName: item.user.nickName,
      avatar: item.user.middleIcon || item.user.bigIcon || item.user.smallIcon,
      userId: item.user.userId,
      likedCount: item.opNumItem.thumbNum,
      replyNum: item.replyTotalCount,
      reply: item.replyComments.map(c => ({
        id: c.replyId,
        text: c.replyInfo,
        time: c.replyTime,

View on GitHub (pinned to 9c364b482e)

Solutions

  1. Log body.code and statusCode before throwing to diagnose.
  2. Give getReplyComment its own _requestObj3 (already declared as null on line 8 but unused) instead of reusing _requestObj2.
  3. Validate replyId is a non-empty string before calling.
  4. Catch in the caller and show 'replies unavailable' for deleted threads.

Example fix

// before — getReplyComment reuses _requestObj2, conflicting with getHotComment
async getReplyComment(musicInfo, replyId, page = 1, limit = 10) {
  if (this._requestObj2) this._requestObj2.cancelHttp()
  const _requestObj2 = httpFetch(...)
  ...
  if (statusCode != 200 || body.code !== '000000') throw new Error('获取回复评论失败')
}

// after — use the declared-but-unused _requestObj3
async getReplyComment(musicInfo, replyId, page = 1, limit = 10) {
  if (this._requestObj3) this._requestObj3.cancelHttp()
  const _requestObj3 = httpFetch(...)
  this._requestObj3 = _requestObj3
  ...
  if (statusCode != 200 || !body || body.code !== '000000') {
    console.warn('mg getReplyComment failed', { statusCode, code: body?.code })
    throw new Error('获取回复评论失败')
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

function isValidReplyRequest(musicInfo, replyId) {
  return !!musicInfo.songId && typeof replyId === 'string' && replyId.length > 0
}

Type guard

function isMiguReplyResponse(body) {
  return body != null && typeof body === 'object' && body.code === '000000' && body.data != null && body.data.mainCommentItem != null
}

Try / catch

try {
  const result = await mgComment.getReplyComment(musicInfo, replyId, page, limit)
} catch (err) {
  if (err.message === '获取回复评论失败') {
    console.warn('Migu reply comments failed for reply', replyId)
    return { source: 'mg', comments: [], total: 0, page, limit, maxPage: 1 }
  }
  throw err
}

Prevention

When it happens

Trigger: Calling getReplyComment(musicInfo, replyId, page, limit) with an invalid or deleted replyId. The parent comment was removed so the thread no longer exists. Concurrent calls to getReplyComment and getHotComment cancel each other via the shared _requestObj2.cancelHttp().

Common situations: User expands a reply thread for a comment that was deleted between fetching the comment list and expanding replies. Rapid navigation between hot comments and reply threads triggers mutual cancellation via the shared _requestObj2.

Related errors


AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12). Data as JSON: /api/errors/3224e91219eec110. Report an issue: GitHub.