Steps to reproduce
- Clone repo,
npm install, npm run build
node dist/cli.js dev --netease --query "ambient focus instrumental"
- The TUI starts but immediately fails during
ensureCandidates()
Expected
NetEase search results are resolved to playable URLs, TUI starts playback.
Actual
[ERR] {
status: 502,
body: {
code: 502,
msg: 'Client network socket disconnected before secure TLS connection was established'
},
cookie: []
}
Root cause
The ensureCandidates() method in netease-tui-adapter.ts calls songUrl() (via song_url_v1) for each search result in a tight loop. The first 1-2 calls fail with a 502 TLS disconnect because the NetEase server drops keep-alive connections from the preceding cloudsearch call. Isolated calls succeed; only rapid sequential calls trigger the issue.
Suggested fix
Two changes:
netease-tui-adapter.ts ensureCandidates() — add ~800ms delay between songUrl() calls
netease-adapter.ts — add a retry helper for 502 / socket-disconnect errors (retry up to 2x with 1s delay), applied to both search() and songUrl()
These two changes make dev --netease work reliably on Windows + Node v24.14.0.
Steps to reproduce
npm install,npm run buildnode dist/cli.js dev --netease --query "ambient focus instrumental"ensureCandidates()Expected
NetEase search results are resolved to playable URLs, TUI starts playback.
Actual
Root cause
The
ensureCandidates()method innetease-tui-adapter.tscallssongUrl()(viasong_url_v1) for each search result in a tight loop. The first 1-2 calls fail with a 502 TLS disconnect because the NetEase server drops keep-alive connections from the precedingcloudsearchcall. Isolated calls succeed; only rapid sequential calls trigger the issue.Suggested fix
Two changes:
netease-tui-adapter.tsensureCandidates()— add ~800ms delay betweensongUrl()callsnetease-adapter.ts— add a retry helper for 502 / socket-disconnect errors (retry up to 2x with 1s delay), applied to bothsearch()andsongUrl()These two changes make
dev --neteasework reliably on Windows + Node v24.14.0.