fix: acp/zed race condition between MCP initialisation and prompt (#20205)

Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
This commit is contained in:
kartik
2026-02-28 23:03:08 +05:30
committed by GitHub
parent 6c65a2d813
commit b2214a6676
5 changed files with 39 additions and 2 deletions
+9 -2
View File
@@ -716,6 +716,7 @@ export class Config implements McpContext {
private compressionTruncationCounter = 0;
private initialized = false;
private initPromise: Promise<void> | undefined;
private mcpInitializationPromise: Promise<void> | null = null;
readonly storage: Storage;
private readonly fileExclusions: FileExclusions;
private readonly eventEmitter?: EventEmitter;
@@ -1124,7 +1125,7 @@ export class Config implements McpContext {
);
// We do not await this promise so that the CLI can start up even if
// MCP servers are slow to connect.
const mcpInitialization = Promise.allSettled([
this.mcpInitializationPromise = Promise.allSettled([
this.mcpClientManager.startConfiguredMcpServers(),
this.getExtensionLoader().start(this),
]).then((results) => {
@@ -1136,7 +1137,7 @@ export class Config implements McpContext {
});
if (!this.interactive || this.experimentalZedIntegration) {
await mcpInitialization;
await this.mcpInitializationPromise;
}
if (this.skillsSupport) {
@@ -2234,6 +2235,12 @@ export class Config implements McpContext {
return this.experimentalZedIntegration;
}
async waitForMcpInit(): Promise<void> {
if (this.mcpInitializationPromise) {
await this.mcpInitializationPromise;
}
}
getListExtensions(): boolean {
return this.listExtensions;
}