fix(mcp): prevent handshake hang when local stdio server exits early#888
Open
harryfan1985 wants to merge 2 commits into
Open
fix(mcp): prevent handshake hang when local stdio server exits early#888harryfan1985 wants to merge 2 commits into
harryfan1985 wants to merge 2 commits into
Conversation
- Add 30s request timeout to MCPConnection::new_local to prevent permanent hang when server process exits before handshake completes - Drain pending request waiters when message channel closes so callers receive a clean error instead of blocking forever - Inject shell PATH on macOS in create_tokio_command so that shebang-driven tools (npx, uvx, node, etc.) resolve correctly when spawned from the GUI app (which has minimal default PATH) - Add 15s Promise.race timeout in McpToolsConfig loadServers as defensive frontend fallback for stuck MCP server loads Closes GCWing#887
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #887 — three related issues that cause the MCP service list to hang on "加载中…" when a local stdio server fails to start.
Changes
1. Add 30s request timeout to local connections (
connection.rs)MCPConnection::new_localpreviously setrequest_timeout: None, causingsend_request_and_waitto block forever when the server process exited before completing the handshake. Now defaults to 30s.2. Drain pending waiters on channel close (
connection.rs)When the message channel closes (server process exits),
handle_messagesnow clears all pendingoneshotwaiters so callers receive a cleanMCPRuntimeErrorinstead of hanging indefinitely.3. Inject shell PATH on macOS (
process_manager.rs)macOS GUI apps have a minimal default PATH (
/usr/bin:/bin:/usr/sbin:/sbin) with no Homebrew paths.create_tokio_commandnow resolves the user's shell PATH viazsh -ilcand injects it so shebang-driven tools (npx, uvx, node, etc.) work correctly.4. Frontend timeout fallback (
McpToolsConfig.tsx)Added a 15s
Promise.racetimeout inloadServersas a defensive UI fallback — ensuressetMcpLoading(false)always runs.