Skip to content

Commit 5cb12b4

Browse files
committed
fix(desktop): wait for owner identity before starting WSL
1 parent 26f45ca commit 5cb12b4

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

‎apps/desktop/src/wsl/DesktopWslBackend.test.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ describe("DesktopWslBackend", () => {
8888
let registeredSpec: DesktopBackendPool.BackendInstanceSpec | undefined;
8989
let registeredWsl: DesktopBackendPool.DesktopBackendInstance | undefined;
9090
let startCount = 0;
91-
const primary = makeStubInstance({
92-
id: DesktopBackendPool.PRIMARY_INSTANCE_ID,
93-
label: "Windows",
94-
snapshot: primarySnapshot,
95-
});
91+
let primaryReadyChecked = false;
92+
const primary = {
93+
...makeStubInstance({
94+
id: DesktopBackendPool.PRIMARY_INSTANCE_ID,
95+
label: "Windows",
96+
snapshot: primarySnapshot,
97+
}),
98+
waitForReady: () =>
99+
Effect.sync(() => {
100+
primaryReadyChecked = true;
101+
return true;
102+
}),
103+
};
96104
const layerPool = Layer.succeed(DesktopBackendPool.DesktopBackendPool, {
97105
get: (id) =>
98106
Effect.succeed(
@@ -104,6 +112,7 @@ describe("DesktopWslBackend", () => {
104112
primary: Effect.succeed(primary),
105113
register: (spec) =>
106114
Effect.sync(() => {
115+
assert.isTrue(primaryReadyChecked);
107116
registeredSpec = spec;
108117
registeredWsl = makeStubInstance({
109118
id: spec.id,

‎apps/desktop/src/wsl/DesktopWslBackend.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as Cause from "effect/Cause";
22
import * as Context from "effect/Context";
33
import * as Effect from "effect/Effect";
4+
import * as Duration from "effect/Duration";
45
import * as Layer from "effect/Layer";
56
import * as Option from "effect/Option";
67
import * as Ref from "effect/Ref";
@@ -92,6 +93,9 @@ export const layer = Layer.effect(
9293
const startNew = Effect.fn("desktop.wslBackend.startNew")(function* (input: {
9394
readonly distro: string | null;
9495
}) {
96+
const primary = yield* pool.primary;
97+
// Readiness creates the owner identity; keep WSL available if the primary cannot start.
98+
yield* primary.waitForReady(Duration.seconds(60));
9599
const primaryConfig = yield* serverExposure.backendConfig;
96100
const port = yield* scanForWslPort(primaryConfig.port + 1).pipe(
97101
Effect.provideService(NetService.NetService, net),

‎apps/web/src/components/sidebar/updateEverything.logic.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ describe("collectServerUpdateTargets", () => {
177177
: { environmentId: "wsl", label: "wsl", reason: "update its owning desktop app" },
178178
);
179179
});
180-
181-
182180
});
183181

184182
describe("collectChannelSwitchTargets", () => {

0 commit comments

Comments
 (0)