fix(app): avoid duplicate bootstrap connection client

This commit is contained in:
Mohamed Boudra
2026-04-22 13:26:45 +07:00
parent 6b210df471
commit 2706d5e934
2 changed files with 16 additions and 29 deletions
+12 -11
View File
@@ -11,6 +11,7 @@ import {
connectionFromListen,
normalizeStoredHostProfile,
upsertHostConnectionInProfiles,
registryHasConnection,
type HostConnection,
type HostProfile,
} from "@/types/host-connection";
@@ -1265,20 +1266,20 @@ export class HostRuntimeStore {
private async bootstrapLocalhost(): Promise<void> {
try {
try {
const { client, serverId, hostname } = await connectToDaemon(
{
id: `bootstrap:${DEFAULT_LOCALHOST_ENDPOINT}`,
type: "directTcp",
endpoint: DEFAULT_LOCALHOST_ENDPOINT,
},
{ timeoutMs: DEFAULT_LOCALHOST_BOOTSTRAP_TIMEOUT_MS },
);
const connection = connectionFromListen(DEFAULT_LOCALHOST_ENDPOINT);
if (!connection || registryHasConnection(this.hosts, connection)) {
return;
}
await this.upsertDirectConnection({
try {
const { client, serverId, hostname } = await connectToDaemon(connection, {
timeoutMs: DEFAULT_LOCALHOST_BOOTSTRAP_TIMEOUT_MS,
});
await this.upsertHostConnection({
serverId,
endpoint: DEFAULT_LOCALHOST_ENDPOINT,
label: hostname ?? undefined,
connection,
existingClient: client,
});
} catch {