fix: make experimental MCP server initialization non-fatal to thv serve#4393
fix: make experimental MCP server initialization non-fatal to thv serve#4393
Conversation
Move mcpserver.New() inside the goroutine so that a failure in MCP server creation (e.g. registry authentication error) only terminates the goroutine instead of crashing the entire thv serve process. The main HTTP API server continues running normally. Fixes #4392 Made-with: Cursor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4393 +/- ##
==========================================
+ Coverage 69.47% 69.52% +0.04%
==========================================
Files 485 485
Lines 49805 49805
==========================================
+ Hits 34603 34625 +22
+ Misses 12523 12502 -21
+ Partials 2679 2678 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jerm-dro
left a comment
There was a problem hiding this comment.
question: What's the use case for thv serve continuing to run when the server fails to start? Continuing without it means the process looks healthy but isn't doing what was asked.
The original crash-on-failure behavior gives immediate, unmissable feedback. Is there a scenario where the rest of the process has independent value?
This issue kills the thv process, including the main HTTP API server ( thv serve). The desktop app cannot do anything cause the process was killed. This happens when a registry is not correctly authenticated, and when you restart the http server and the thv process ( for instance restarting the desktop app), the process cannot be spawned and the http server as well.
Thv serve cannot works if the thv process is not up and running, so I cannot call registry api for authenticating the registry or reset it |
Summary
mcpserver.New()inside the goroutine so that a failure in MCP server creation (e.g., registry authentication error) only terminates the goroutine instead of crashing the entirethv serveprocessFixes #4392
Test plan
thv serve --experimental-mcpwith valid registry credentials → both HTTP API and MCP server start normallythv serve --experimental-mcpwith expired/invalid registry credentials → HTTP API starts normally, MCP failure is logged but process stays alivethv servewithout--experimental-mcp→ no change in behavior