Skip to content

Commit 666bae3

Browse files
committed
Fix hanging in activation when a server-side folder connection is inactive
1 parent 5f160b3 commit 666bae3

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
"editor.tabSize": 2,
55
"editor.formatOnSave": true
66
},
7+
"js/ts.tsdk.path": "node_modules/typescript/lib",
78
}

src/api/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
checkConnection,
1313
schemas,
1414
checkingConnection,
15+
inactiveServerIds,
1516
} from "../extension";
1617
import { currentWorkspaceFolder, outputChannel, outputConsole } from "../utils";
1718

@@ -232,7 +233,7 @@ export class AtelierAPI {
232233
} = getResolvedConnectionSpec(serverName, config("intersystems.servers", workspaceFolderName).get(serverName));
233234
this._config = {
234235
serverName,
235-
active: this.externalServer || conn.active,
236+
active: !inactiveServerIds.has(serverName),
236237
apiVersion: workspaceState.get(this.configName.toLowerCase() + ":apiVersion", DEFAULT_API_VERSION),
237238
serverVersion: workspaceState.get(this.configName.toLowerCase() + ":serverVersion", DEFAULT_SERVER_VERSION),
238239
https: scheme === "https",
@@ -245,13 +246,6 @@ export class AtelierAPI {
245246
pathPrefix,
246247
docker: false,
247248
};
248-
249-
// Report server as inactive when no namespace has been determined,
250-
// otherwise output channel reports the issue.
251-
// This arises when a server-only workspace is editing the user's settings.json, or the .code-workspace file.
252-
if (this._config.ns === "" && this.externalServer) {
253-
this._config.active = false;
254-
}
255249
} else if (conn["docker-compose"]) {
256250
// Provided a docker-compose type connection spec has previously been resolved we can use its values
257251
const resolvedSpec = getResolvedConnectionSpec(workspaceFolderName, undefined);

src/extension.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ export function getResolvedConnectionSpec(key: string, dflt: any): any {
338338
return dflt;
339339
}
340340

341+
/** The `api.serverId`s of all servers that are known to be inactive */
342+
export const inactiveServerIds: Set<string> = new Set();
343+
341344
export async function checkConnection(
342345
clearCookies = false,
343346
uri?: vscode.Uri,
@@ -432,9 +435,8 @@ export async function checkConnection(
432435
handleError(message);
433436
panel.text = `${PANEL_LABEL} $(error)`;
434437
panel.tooltip = `ERROR - ${message}`;
435-
if (!api.externalServer) {
436-
await setConnectionState(configName, false);
437-
}
438+
inactiveServerIds.add(api.serverId);
439+
if (!api.externalServer) await setConnectionState(configName, false);
438440
return;
439441
}
440442
checkingConnection = true;
@@ -448,9 +450,8 @@ export async function checkConnection(
448450
} else {
449451
panel.tooltip = new vscode.MarkdownString(`Connected as \`${username}\``);
450452
}
451-
if (!api.externalServer) {
452-
await setConnectionState(configName, true);
453-
}
453+
inactiveServerIds.delete(api.serverId);
454+
if (!api.externalServer) await setConnectionState(configName, true);
454455
return;
455456
};
456457

@@ -503,7 +504,8 @@ export async function checkConnection(
503504
});
504505
}
505506
} else {
506-
await setConnectionState(configName, false);
507+
inactiveServerIds.add(api.serverId);
508+
if (!api.externalServer) await setConnectionState(configName, false);
507509
}
508510
} else {
509511
success = await new Promise<boolean>((resolve) => {
@@ -535,8 +537,9 @@ export async function checkConnection(
535537
checkingConnection = false;
536538
})
537539
);
538-
} else if (!api.externalServer) {
539-
await setConnectionState(configName, false);
540+
} else {
541+
inactiveServerIds.add(api.serverId);
542+
if (!api.externalServer) await setConnectionState(configName, false);
540543
}
541544
resolve(false);
542545
});
@@ -554,7 +557,8 @@ export async function checkConnection(
554557
);
555558
panel.text = `${connInfo} $(error)`;
556559
panel.tooltip = `ERROR - ${message}`;
557-
await setConnectionState(configName, false);
560+
inactiveServerIds.add(api.serverId);
561+
if (!api.externalServer) await setConnectionState(configName, false);
558562
})
559563
.finally(() => {
560564
checkingConnection = false;

0 commit comments

Comments
 (0)