gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Fix unhandled promise rejection in MCP client manager

Open kamja44 opened this issue 2 months ago • 2 comments

What happened?

The addOrUpdateServer() method in packages/core/src/tools/mcp-client-manager.ts has an unhandled promise rejection issue. When errors occur during MCP client initialization (e.g., in the McpClient constructor or disconnect method), they are not properly caught, leading to unhandled promise rejections that can crash the Node.js process.

The Promise constructor receives a _reject parameter that is never used, and the async IIFE has no .catch() handler, causing errors thrown before the try block to become unhandled rejections.

What did you expect to happen?

Errors during MCP server initialization should be caught and handled gracefully. Specifically:

  • Errors should be logged with clear error messages via coreEvents.emitFeedback
  • One MCP server failure should not prevent other servers from starting
  • The Node.js process should not crash with UnhandledPromiseRejectionWarning
  • Users should see helpful error messages indicating which server failed and why

Client information

Client Information

Platform: Linux (WSL2)

Run gemini to enter the interactive CLI, then run the /about command.

> /about
Gemini CLI v0.21.0-nightly.20251207.025e450ac
Node.js: v20.19.3
OS: Linux 6.6.87.2-microsoft-standard-WSL2

Login information

No response

Anything else we need to know?

No response

kamja44 avatar Dec 08 '25 10:12 kamja44