lyswhut/lx-music-desktop · error · Error
获取热门评论失败
Error message
获取热门评论失败
What it means
Thrown by QQ Music's getHotComment when the newer musicu.fcg endpoint at https://u.y.qq.com/cgi-bin/musicu.fcg returns non-200, body.code !== 0, OR body.req.code !== 0. This is the only error with a double-nested code check (both the outer envelope and the inner req object must report success). Uses HTTPS and a POST with a JSON body (module: music.globalComment.CommentRead, method: GetHotCommentList). Reads body.req.data.CommentList.
Source
Thrown at src/renderer/utils/musicSdk/tx/comment.js:185
BizId: String(songId),
LastCommentSeqNo: '',
PageSize: limit,
PageNum: page - 1,
HotType: 1,
WithAirborne: 0,
PicEnable: 1,
},
},
},
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.0.0',
referer: 'https://y.qq.com/',
origin: 'https://y.qq.com',
},
})
const { body, statusCode } = await _requestObj2.promise
// console.log('body', body)
if (statusCode != 200 || body.code !== 0 || body.req.code !== 0) throw new Error('获取热门评论失败')
const comment = body.req.data.CommentList
return {
source: 'tx',
comments: this.filterHotComment(comment.Comments),
total: comment.Total,
page,
limit,
maxPage: Math.ceil(comment.Total / limit) || 1,
}
},
filterNewComment(rawList) {
return rawList.map(item => {
let time = this.formatTime(item.time)
let timeStr = time ? dateFormat2(time) : null
if (item.middlecommentcontent) {
let firstItem = item.middlecommentcontent[0]
firstItem.avatarurl = item.avatarurl
firstItem.praisenum = item.praisenumView on GitHub (pinned to 9c364b482e)
Solutions
- Log body.code, body.req.code, and statusCode separately to identify which layer failed.
- Update the module/method strings to match the current QQ Music web client by inspecting y.qq.com network traffic.
- Update the User-Agent string periodically to match current Chrome/Edge versions.
- Retry with backoff for transient failures.
- Fall back to the legacy fcg_global_comment endpoint if musicu.fcg is blocked.
Example fix
// before
if (statusCode != 200 || body.code !== 0 || body.req.code !== 0) throw new Error('获取热门评论失败')
// after
if (statusCode != 200 || !body || body.code !== 0 || !body.req || body.req.code !== 0) {
console.warn('tx getHotComment failed', { statusCode, code: body?.code, reqCode: body?.req?.code })
throw new Error('获取热门评论失败')
} Defensive patterns
Strategy: try-catch
Validate before calling
function hasTxSongId(mInfo) {
return mInfo != null && (!!mInfo.songId || !!mInfo.songmid)
} Type guard
function isTxHotCommentResponse(body) {
return body != null && typeof body === 'object' && body.code === 0 && body.req != null && body.req.code === 0 && body.req.data != null
} Try / catch
try {
const result = await txComment.getHotComment(mInfo, page, limit)
} catch (err) {
if (err.message === '获取热门评论失败') {
console.warn('QQ Music hot comments unavailable for', mInfo.songmid)
return { source: 'tx', comments: [], total: 0, page, limit, maxPage: 1 }
}
throw err
} Prevention
- Log both body.code and body.req.code separately to identify which layer failed.
- Keep the module/method strings updated to match the current QQ Music web client.
- Update the User-Agent periodically to avoid bot-detection flagging.
- Fall back to the legacy fcg_global_comment endpoint if musicu.fcg is blocked.
- Retry with backoff for transient failures.
When it happens
Trigger: Calling getHotComment(mInfo, page, limit) where the outer envelope succeeds (body.code === 0) but the inner request fails (body.req.code !== 0), or vice versa. Tencent changes the module/method path. The song has no hot comments. Rate-limiting or anti-bot detection rejects the request at either layer.
Common situations: Tencent's musicu.fcg is an anti-scraping endpoint that frequently changes its module/method contract. The inner req.code may be non-zero for geo-restricted or removed songs. The Chrome/Edge User-Agent string may be flagged and blocked by Tencent's bot detection over time.
Related errors
AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12).
Data as JSON: /api/errors/7498ee21b56dee13.
Report an issue: GitHub.