Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed issue with placeholder connection being removed too early #189

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/services/ServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ export class ServerManager implements IServerManager {

let tagId: UniqueID | undefined;

let placeholderUrl: URL | undefined;

// Pip managed local server
if (serverState.isManaged) {
this.updateConnectionCount(serverUrl, 1);
Expand All @@ -199,10 +201,7 @@ export class ServerManager implements IServerManager {
tagId = uniqueId();

// Put a placeholder connection in place until the worker is ready.
const placeholderUrl = this.addWorkerPlaceholderConnection(
serverUrl,
tagId
);
placeholderUrl = this.addWorkerPlaceholderConnection(serverUrl, tagId);

let workerInfo: WorkerInfo;
try {
Expand All @@ -227,9 +226,6 @@ export class ServerManager implements IServerManager {
return null;
}

// Remove placeholder connection
this.removeWorkerPlaceholderConnection(placeholderUrl);

// Map the worker URL to the server URL to make things easier to dispose
// later.
this._workerURLToServerURLMap.set(new URL(workerInfo.grpcUrl), serverUrl);
Expand All @@ -242,7 +238,14 @@ export class ServerManager implements IServerManager {
const connection = this._dhcServiceFactory.create(serverUrl, tagId);

// Initialize client + prompt for login if necessary
if (!(await connection.getClient())) {
const isClientConnected = await connection.getClient();

// Cleanup placeholder connection if one exists
if (placeholderUrl) {
this.removeWorkerPlaceholderConnection(placeholderUrl);
}

if (!isClientConnected) {
return null;
}

Expand Down
Loading