Skip to content

fix(patch): cherry-pick 9590a09 to release/v0.29.0-preview.4-pr-18771 to patch version v0.29.0-preview.4 and create version 0.29.0-preview.5#19274

Merged
skeshive merged 1 commit intorelease/v0.29.0-preview.4-pr-18771from
hotfix/v0.29.0-preview.4/0.29.0-preview.5/preview/cherry-pick-9590a09/pr-18771
Feb 17, 2026
Merged

fix(patch): cherry-pick 9590a09 to release/v0.29.0-preview.4-pr-18771 to patch version v0.29.0-preview.4 and create version 0.29.0-preview.5#19274
skeshive merged 1 commit intorelease/v0.29.0-preview.4-pr-18771from
hotfix/v0.29.0-preview.4/0.29.0-preview.5/preview/cherry-pick-9590a09/pr-18771

Conversation

@gemini-cli-robot
Copy link
Collaborator

This PR automatically cherry-picks commit 9590a09 to patch version v0.29.0-preview.4 in the preview release to create version 0.29.0-preview.5.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gemini-cli-robot, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request automates the cherry-picking of a specific commit to create a new patch version for a preview release. The primary technical change involves streamlining the MCP client connection process by refactoring the connectToMcpServer function to directly return the client, thereby abstracting away the explicit management of the underlying transport mechanism. This simplifies the client's API and internal logic for connection handling.

Highlights

  • Automated Cherry-Pick: This pull request automatically cherry-picks commit 9590a09 to create a new patch version v0.29.0-preview.5 for the v0.29.0-preview.4 preview release.
  • Simplified MCP Client Connection API: The connectToMcpServer function has been refactored to return only the Client instance, abstracting away the explicit management of the underlying transport mechanism.
  • Internalized Transport Handling: Explicit handling and closing of the transport object have been removed from McpClient and connectAndDiscover functions, making the transport's lifecycle internal to the connection process.
  • Test Updates: Related test files have been updated to reflect the changes in connectToMcpServer's return type and the mocking of StdioClientTransport.
Changelog
  • packages/core/src/tools/mcp-client.test.ts
    • Updated StdioClientTransport mock to return an empty object instead of one with a close function.
    • Adjusted expect statements to directly assert on the client object returned by connectToMcpServer instead of client.client.
  • packages/core/src/tools/mcp-client.ts
    • Modified McpClient.connect to directly assign the result of connectToMcpServer to this.client and removed this.transport.
    • Removed transport closing logic from onerror handlers in McpClient and connectAndDiscover.
    • Updated connectAndDiscover to directly assign the result of connectToMcpServer to mcpClient and removed transport variable.
    • Changed connectWithSSETransport and retryWithOAuth functions to return Promise<void> instead of Promise<Transport>.
    • Updated connectToMcpServer to return Promise<Client> instead of Promise<{ client: Client; transport: Transport }>.
    • Adjusted return statements in connectToMcpServer to return only the mcpClient instance.
Activity
  • This pull request was automatically generated as part of a release process to cherry-pick a commit and create a new patch version.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@skeshive skeshive enabled auto-merge (squash) February 17, 2026 19:00
@github-actions
Copy link

Size Change: -810 B (0%)

Total Size: 23.9 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 23.9 MB -810 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request refactors the MCP connection logic to return only the Client instance instead of a { client, transport } object. While this simplifies the API, it introduces resource leaks in the onerror handlers because the explicit transport closing logic was removed but not replaced with client.close(). Additionally, the McpClient class now contains dead code and an uninitialized transport property that breaks its internal cleanup logic.

Comment on lines +145 to 152
this.client = await connectToMcpServer(
this.clientVersion,
this.serverName,
this.serverConfig,
this.debugMode,
this.workspaceContext,
this.cliConfig.sanitizationConfig,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The removal of the this.transport = transport assignment leaves the transport property of the McpClient class (defined at line 112) permanently uninitialized. This breaks the cleanup logic in the disconnect() method (lines 213-215), which still attempts to close this.transport. Since connectToMcpServer now only returns the Client instance, the direct reference to the transport is lost. To maintain correctness, the transport property should be removed from the class, and the disconnect() method should be updated to rely solely on this.client.close() (which internally closes the transport).

Comment on lines +926 to 929
mcpClient.onerror = (error) => {
coreEvents.emitFeedback('error', `MCP ERROR (${mcpServerName}):`, error);
updateMCPServerStatus(mcpServerName, MCPServerStatus.DISCONNECTED);
// Close transport to prevent memory leaks
if (transport) {
try {
await transport.close();
} catch {
// Ignore errors when closing transport on error
}
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the McpClient class, the onerror handler in connectAndDiscover no longer performs cleanup. While the catch block at the end of the function handles errors during the discovery process, an asynchronous error triggered via onerror should also ensure the client is closed to prevent leaking resources like subprocesses or network connections.

Suggested change
mcpClient.onerror = (error) => {
coreEvents.emitFeedback('error', `MCP ERROR (${mcpServerName}):`, error);
updateMCPServerStatus(mcpServerName, MCPServerStatus.DISCONNECTED);
// Close transport to prevent memory leaks
if (transport) {
try {
await transport.close();
} catch {
// Ignore errors when closing transport on error
}
}
};
mcpClient.onerror = (error) => {
coreEvents.emitFeedback('error', `MCP ERROR (${mcpServerName}):`, error);
updateMCPServerStatus(mcpServerName, MCPServerStatus.DISCONNECTED);
mcpClient?.close().catch(() => {});
};

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 17, 2026
@skeshive skeshive merged commit b3ac129 into release/v0.29.0-preview.4-pr-18771 Feb 17, 2026
27 checks passed
@skeshive skeshive deleted the hotfix/v0.29.0-preview.4/0.29.0-preview.5/preview/cherry-pick-9590a09/pr-18771 branch February 17, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants