Skip to content

Commit 158874c

Browse files
committed
fix: install prompt
1 parent 5fb4998 commit 158874c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/cm/lsp/serverLauncher.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import loader from "dialogs/loader";
44

55
const managedServers = new Map();
66
const checkedCommands = new Map();
7+
const pendingInstallChecks = new Map();
78
const announcedServers = new Set();
89

910
const STATUS_PRESENT = "present";
@@ -89,10 +90,29 @@ async function ensureInstalled(server) {
8990
if (!launcher?.checkCommand) return true;
9091

9192
const cacheKey = `${server.id}:${launcher.checkCommand}`;
93+
94+
// Return cached result if already checked
9295
if (checkedCommands.has(cacheKey)) {
9396
return checkedCommands.get(cacheKey) === STATUS_PRESENT;
9497
}
9598

99+
// If there's already a pending check for this server, wait for it
100+
if (pendingInstallChecks.has(cacheKey)) {
101+
return pendingInstallChecks.get(cacheKey);
102+
}
103+
104+
// Create and track the pending promise
105+
const checkPromise = performInstallCheck(server, launcher, cacheKey);
106+
pendingInstallChecks.set(cacheKey, checkPromise);
107+
108+
try {
109+
return await checkPromise;
110+
} finally {
111+
pendingInstallChecks.delete(cacheKey);
112+
}
113+
}
114+
115+
async function performInstallCheck(server, launcher, cacheKey) {
96116
try {
97117
await runCommand(launcher.checkCommand);
98118
checkedCommands.set(cacheKey, STATUS_PRESENT);

0 commit comments

Comments
 (0)