Binaryify / NeteaseCloudMusicApi

网易云音乐 Node.js API service
https://gitlab.com/Binaryify/neteasecloudmusicapi
30.28k stars 15.79k forks source link

项目运行成功 请求一进来就报错 UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON #1144

Closed Hjw52 closed 2 years ago

Hjw52 commented 3 years ago

环境

出现问题

项目拉下来 npm run start 成功,但是前端项目起来(自己的前端),前端请求一进来就报错:TypeError: Converting circular structure to JSON。初步了解JSON.stringify转换时出现了循环引用 但我不大了解哪里的循环引用。你们没出现这个错误吗? `(node:19220) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON

--> starting at object with constructor 'Object' | property 'httpsAgent' -> object with constructor 'Agent' | property 'sockets' -> object with constructor 'Object' | ... | property 'errored' -> object with constructor 'Object' --- property 'config' closes the circle at JSON.stringify () at stringify (D:\VsCode\musicApi\NeteaseCloudMusicApi-master\NeteaseCloudMusicApi-master\NeteaseCloudMusieCloudMusicApi-master\node_modules\express\lib\response.js:260:14) at ServerResponse.send (D:\VsCode\musicApi\NeteaseCloudMusicApi-master\NeteaseCloudMusicApi-master\NeteaseCloudMusicApi-master\node_modules\express\lib\response.js:158:21) at D:\VsCode\musicApi\NeteaseCloudMusicApi-master\NeteaseCloudMusicApi-master\NeteaseCloudMusicApi-master\app.js:105:37 at processTicksAndRejections (internal/process/task_queues.js:93:5)`

重现步骤

本地运行,项目一起来 请求进来就报错。

期待效果

希望遇到同样错误的人能解答下。


Hjw52 commented 3 years ago

错误定位行 app.js:105 res.status(answer.status).send(answer.body)

zhengdechang commented 3 years ago

我也是这样,首先是502无法识别第一个证书。然后就是你这个错误了。

zhengdechang commented 3 years ago

[ERR] /artist/top/song?id=6452 { status: 502, body: { code: 502, msg: Error: unable to verify the first certificate at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34) at TLSSocket.emit (events.js:315:20) at TLSSocket._finishInit (_tls_wrap.js:932:8) at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12) { code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE', config: [Object], request: [Writable], response: undefined, isAxiosError: true, toJSON: [Function: toJSON] } } } (node:2420) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON --> starting at object with constructor 'Object' | property 'httpsAgent' -> object with constructor 'Agent' | property 'sockets' -> object with constructor 'Object' | ... | property 'errored' -> object with constructor 'Object' --- property 'config' closes the circle at JSON.stringify () at stringify (F:\elemusic\NeteaseCloudMusicApi\node_modules_express@4.17.1@express\lib\response.js:1123:12) at ServerResponse.json (F:\elemusic\NeteaseCloudMusicApi\node_modules_express@4.17.1@express\lib\response.js:260:14) at ServerResponse.send (F:\elemusic\NeteaseCloudMusicApi\node_modules_express@4.17.1@express\lib\response.js:158:21) at F:\elemusic\NeteaseCloudMusicApi\app.js:105:37 at processTicksAndRejections (internal/process/task_queues.js:93:5) (Use node --trace-warnings ... to show where the warning was created) (node:2420) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a pr omise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.h tml#cli_unhandled_rejections_mode). (rejection id: 2) (node:2420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non -zero exit code.

Binaryify commented 3 years ago

把代理关了,或者 环境变量http_proxy和 https_proxy 都设为空

zhengdechang commented 3 years ago

我没有使用代理啊------------------ 原始邮件 ------------------ 发件人: "binaryify"<notifications@github.com> 发送时间: 2021年2月22日(星期一) 下午5:39 收件人: "Binaryify/NeteaseCloudMusicApi"<NeteaseCloudMusicApi@noreply.github.com>; 抄送: "zhengdechang"<2473023641@qq.com>;"Comment"<comment@noreply.github.com>; 主题: Re: [Binaryify/NeteaseCloudMusicApi] 项目运行成功 请求一进来就报错 UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON (#1144)

Binaryify commented 3 years ago

装了 unblockneteasemusic 的证书?国外的服务器?

zhengdechang commented 3 years ago

我用的是cnpm,应该算是国内的服务器,以前一直用可以,这两天开始就不能用了,没有更新什么,突然就这样了------------------ 原始邮件 ------------------ 发件人: "binaryify"<notifications@github.com> 发送时间: 2021年2月22日(星期一) 下午5:55 收件人: "Binaryify/NeteaseCloudMusicApi"<NeteaseCloudMusicApi@noreply.github.com>; 抄送: "zhengdechang"<2473023641@qq.com>;"Comment"<comment@noreply.github.com>; 主题: Re: [Binaryify/NeteaseCloudMusicApi] 项目运行成功 请求一进来就报错 UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON (#1144)

Binaryify commented 3 years ago

你ping music.163.com 一下

zhengdechang commented 3 years ago

正在 Ping bgpv6.music.ntes53.netease.com [59.111.181.35] 具有 32 字节的数据: 来自 59.111.181.35 的回复: 字节=32 时间=37ms TTL=50 来自 59.111.181.35 的回复: 字节=32 时间=37ms TTL=50 来自 59.111.181.35 的回复: 字节=32 时间=37ms TTL=50 来自 59.111.181.35 的回复: 字节=32 时间=37ms TTL=50

59.111.181.35 的 Ping 统计信息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失), 往返行程的估计时间(以毫秒为单位): 最短 = 37ms,最长 = 37ms,平均 = 37ms

zhengdechang commented 3 years ago

ping之后这样

zhengdechang commented 3 years ago

这个问题能解决吗

Binaryify commented 3 years ago

把 request.js 里的

   httpAgent: new http.Agent({ keepAlive: true }),
   httpsAgent: new https.Agent({ keepAlive: true }),

去掉试试

zhengdechang commented 3 years ago

还是一样,虽然在postman有反应,但是还是502问题------------------ 原始邮件 ------------------ 发件人: "binaryify"<notifications@github.com> 发送时间: 2021年2月22日(星期一) 晚上8:54 收件人: "Binaryify/NeteaseCloudMusicApi"<NeteaseCloudMusicApi@noreply.github.com>; 抄送: "zhengdechang"<2473023641@qq.com>;"Comment"<comment@noreply.github.com>; 主题: Re: [Binaryify/NeteaseCloudMusicApi] 项目运行成功 请求一进来就报错 UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON (#1144)

zhengdechang commented 3 years ago

{ "code": 502, "msg": { "message": "unable to verify the first certificate", "name": "Error", "stack": "Error: unable to verify the first certificate\n at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)\n at TLSSocket.emit (events.js:315:20)\n at TLSSocket._finishInit (_tls_wrap.js:932:8)\n at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12)", "config": { "url": "https://music.163.com/weapi/artist/top/song", "method": "post", "data": "params=58TGdhl9GUCPeL%2BQdJJqvHyuzuC8eCkc6yWO0ADuUZ6BI%2BlaukQGk9DD58E%2F7q%2Bc&encSecKey=0ec9fe196fdb3a9348885e2f24eddfb5507484552e3729b1167295615637ebc3c17d64c219e1c8bb89114bd484f863131ebcee5191f46db8a004d0ccb5a50a1a6219362503baeb7b48812e78e8ef123d72e1d9e7b3e7fcb6e4d47ebe1332b3b4c4fe62b136a489c18914654a07375e5d0ebe5acb60cce706010abb1bb33f9260", "headers": { "Accept": "application/json, text/plain, /", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0", "Referer": "https://music.163.com", "Cookie": "NMTID=00OycM8eHUIDiOZgkgunGwb561HQcgAAAF3eFOmpg", "Content-Length": 346 }, "transformRequest": [ null ], "transformResponse": [ null ], "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "maxBodyLength": -1 }, "code": "UNABLE_TO_VERIFY_LEAF_SIGNATURE" } }

zhengdechang commented 3 years ago

是我一个人有这问题吗 还是其他人也有 或者有没有可能是npm的问题

Binaryify commented 3 years ago

set NODE_TLS_REJECT_UNAUTHORIZED=0 && node app.js 试试

zhengdechang commented 3 years ago

还是一样的问题,没什么改变

Hjw52 commented 3 years ago

我的是套接字报错: [ERR] /banner?type=2 { status: 502, body: { code: 502, msg: Error: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20) { errno: -4077, code: 'ECONNRESET', syscall: 'read', config: [Object], request: [Writable], response: undefined, isAxiosError: true, toJSON: [Function: toJSON] } } }

zhengdechang commented 3 years ago

博主有解决方案了吗

Hjw52 commented 3 years ago

博主有解决方案了吗

我发现我们是不同的问题,我那个问题 之前issue说是了公司网络问题,我下班用自己网络测看看。

zhengdechang commented 3 years ago

如果你能用,麻烦告诉一声,我的项目停了好几天了

Hjw52 commented 3 years ago

如果你能用,麻烦告诉一声,我的项目停了好几天了

我的换个网络可以。

zhengdechang commented 3 years ago

webstorm的git显示需要登录github,才能识别证书,是怎么回事

cccKiss commented 3 years ago

webstorm的git显示需要登录github,才能识别证书,是怎么回事

我这边报了和你相同的问题,原因是公司内网限制,你手机开启热点,使用手机网络运行正常。