Skip to content

Fix unhandled promise rejection in MCP client manager #14700

@kamja44

Description

@kamja44

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

Metadata

Metadata

Labels

area/coreIssues related to User Interface, OS Support, Core Functionalitypriority/p1Important and should be addressed in the near term.status/possible-duplicate

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions