google-gemini / google-gemini/gemini-cli
IdeServer.stop() never resolves while an MCP session is open
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
### What happened?
`IdeServer.stop()` in `packages/vscode-ide-companion/src/ide-server.ts` awaits `this.server.close()`:
```ts
await new Promise((resolve, reject) => {
this.server!.close((err?: Error) => {
if (err) { ...reject(err); }
this.log(`IDE server shut down`);
resolve();
});
});
```
`http.Server.close()` stops accepting new connections but does not terminate established ones, and its callback fires only once all connections drain. The MCP transport holds a long-lived streaming response on `GET /mcp`, so nothing drains and the callback never fires. `stop()` never resolves, and extension deactivate blocks behind it.
`stop()` never iterates `this.transports` to close them, and never calls `closeAllConnections()`.
Because `transport.onclose` never fires either, the 60-second keep-alive interval is never cleared and keeps sending pings against a server that is supposed to be gone.
Reproducing the mechanism with a plain Node server in the same shape (one open streaming response, then `close()`):
```
client stream open; calling server.close() as stop() does
RESULT: close callback NEVER fired -> stop() hangs, deactivate blocks
after closeAllConnections(): callback fired
```
There is a second issue in the same keep-alive block: `missedPings` is reset to `0` on every success, so a transport that alternates success and failure never reaches the `>= 3` threshold and the interval is never cleared on that path either.
### What did you expect to happen?
`stop()` resolves promptly, open MCP transports are closed, and the keep-alive interval is cleared.
### Client information
Client Information
This is a source-level report rather than a runtime one, so there is no `/about` output. Verified against:
```console
repository checkout: 4238b0b
package version: 0.56.0-nightly.20260806.g761f604c1
published CLI: 0.52.0
node: v24.10.0
OS: macOS 26.5.1
```
### Anything else we need to know?
Reachable whenever a user has `ide-mode` connected and then disables, reloads, or updates the extension. VS Code reports the extension as unresponsive on shutdown.
Fix direction: close every entry in `this.transports` (which triggers `onclose` and clears the interval) and call `closeAllConnections()` alongside `close()`. The reproduction above confirms `closeAllConnections()` releases the callback.
Contributor guide
Research direction
Start in packages/vscode-ide-companion/src/ide-server.ts at IdeServer.stop() and the keep-alive block, then inspect how this.transports and transport.onclose are connected. Reproduce the open GET /mcp streaming-response case described in the issue; done means stop() resolves promptly, open MCP transports close, and the keep-alive interval is cleared.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100