Allow prompt queueing during MCP initialization (#17395)

This commit is contained in:
Adib234
2026-01-23 18:32:06 -05:00
committed by GitHub
parent 93da9817b6
commit 12a5490bcf
8 changed files with 234 additions and 155 deletions
@@ -279,6 +279,7 @@ export class McpClientManager {
if (currentPromise === this.discoveryPromise) {
this.discoveryPromise = undefined;
this.discoveryState = MCPDiscoveryState.COMPLETED;
this.eventEmitter?.emit('mcp-client-update', this.clients);
}
})
.catch(() => {}); // Prevents unhandled rejection from the .finally branch
@@ -307,6 +308,12 @@ export class McpClientManager {
this.cliConfig.getMcpServerCommand(),
);
if (Object.keys(servers).length === 0) {
this.discoveryState = MCPDiscoveryState.COMPLETED;
this.eventEmitter?.emit('mcp-client-update', this.clients);
return;
}
// Set state synchronously before any await yields control
if (!this.discoveryPromise) {
this.discoveryState = MCPDiscoveryState.IN_PROGRESS;