lyswhut/lx-music-desktop · error · Error
获取热门评论失败
Error message
获取热门评论失败
What it means
Thrown by Migu's getHotComment when the hot comment endpoint at https://app.c.nf.migu.cn/MIGUM3.0/user/comment/stack/v1.0 (queryType=2) returns non-200 or body.code !== '000000'. Same guard as error 45 but for hot comments. Reads body.data.cfgHotCount and body.data.hotComments. Note the message says '获取热门评论失败' (hot comment failed), distinguishing it from the regular comment failure.
Solutions
- Log body.code and statusCode to identify the failure type.
- Distinguish 'no hot comments' from 'API error' — return an empty list if body.code indicates empty results.
- Retry with backoff for transient failures.
- Fall back to regular comments if hot comments are unavailable.
Example fix
// before
if (statusCode != 200 || body.code !== '000000') throw new Error('获取热门评论失败')
// after
if (statusCode != 200 || !body || body.code !== '000000') {
console.warn('mg getHotComment API failed', { statusCode, code: body?.code })
throw new Error('获取热门评论失败')
} Defensive patterns
Strategy: try-catch
Validate before calling
function isValidMiguSongId(songId) {
return typeof songId === 'string' && songId.length > 0
} Type guard
function isMiguHotCommentResponse(body) {
return body != null && typeof body === 'object' && body.code === '000000' && body.data != null
} Try / catch
try {
const result = await mgComment.getHotComment(musicInfo, page, limit)
} catch (err) {
if (err.message === '获取热门评论失败') {
console.warn('Migu hot comments API failed for', musicInfo.songId)
return { source: 'mg', comments: [], total: 0, page, limit, maxPage: 1 }
}
throw err
} Prevention
- Treat 'no hot comments' as an empty result, not an error.
- Log body.code to distinguish empty results from API errors.
- Retry with backoff for transient rate-limiting.
- Fall back to regular comments if hot comments are unavailable.
When it happens
Trigger: The hot comment endpoint returns an error for songs with no hot comments. Rate-limiting from Migu. Invalid resourceId. Network interference with app.c.nf.migu.cn.
Common situations: Low-popularity songs have no hot comments, so Migu returns a non-success code. Repeated rapid calls trigger rate-limiting. The endpoint contract changed (body.code format).
Related errors
AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12).
Data as JSON: /api/errors/ab33c881ce147cd2.
Report an issue: GitHub.
Appendix: source
Thrown at src/renderer/utils/musicSdk/mg/comment.js:53
async getHotComment(musicInfo, page = 1, limit = 20) {
if (this._requestObj2) this._requestObj2.cancelHttp()
if (!musicInfo.songId) {
let id = await getSongId(musicInfo)
if (!id) throw new Error('获取评论失败')
musicInfo.songId = id
}
// const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listTopComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, {
const _requestObj2 = httpFetch(`https://app.c.nf.migu.cn/MIGUM3.0/user/comment/stack/v1.0?pageSize=${limit}&queryType=2&resourceId=${musicInfo.songId}&resourceType=2&hotCommentStart=${(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',
// Referer: 'https://music.migu.cn',
},
})
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 }
},View on GitHub (pinned to 9c364b482e)