Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

LocalDeviceHost.test.ts

605 lines23.0 KB

1import { describe, expect, it } from "@effect/vitest";
2import * as NodePath from "@effect/platform-node/NodePath";
3import * as HostProcess from "@t3tools/shared/HostProcess";
4import * as Effect from "effect/Effect";
5import * as Layer from "effect/Layer";
6import * as Option from "effect/Option";
7import * as Path from "effect/Path";
8import * as PlatformError from "effect/PlatformError";
9import * as Ref from "effect/Ref";
10import * as FileSystem from "effect/FileSystem";
11import * as Sink from "effect/Sink";
12import * as Stream from "effect/Stream";
13​
14import * as LocalDeviceHost from "./LocalDeviceHost.ts";
15import * as NodeServices from "@effect/platform-node/NodeServices";
16import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
17import { HttpClient, HttpClientResponse } from "effect/http";
18import * as NetService from "@t3tools/shared/Net";
19import * as ServerConfig from "../config.ts";
20import * as ProcessRunner from "../processRunner.ts";
21import {
22 AGENT_DEVICE_VERSION,
23 DEVICE_HUB_VERSION,
24 agentDeviceStateDir,
25} from "./DeviceToolchain.ts";
26​
27const processOutput = (code: number, stdout = "", stderr = "", timedOut = false) => ({
28 code: ChildProcessSpawner.ExitCode(code),
29 stdout,
30 stderr,
31 timedOut,
32 stdoutTruncated: false,
33 stderrTruncated: false,
34 stdoutInvalidUtf8: false,
35 stderrInvalidUtf8: false,
36});
37​
38const agentFixture = Effect.fn("agentFixture")(function* (
39 startup: (
40 stateDir: string,
41 ) => Effect.Effect<ProcessRunner.ProcessRunOutput, ProcessRunner.ProcessRunError>,
42 avdOutput: ProcessRunner.ProcessRunOutput = processOutput(0),
43) {
44 const fs = yield* FileSystem.FileSystem;
45 const path = yield* Path.Path;
46 const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-device-agent-start-" });
47 const hub = { running: true, spawnFails: false };
48 const stateDir = agentDeviceStateDir(path, path.join(baseDir, "userdata"));
49 const daemonHealthy = yield* Ref.make(true);
50 for (const [name, version, entry] of [
51 ["expo-device-hub", DEVICE_HUB_VERSION, "dist/server/cli.mjs"],
52 ["agent-device", AGENT_DEVICE_VERSION, "bin/agent-device.mjs"],
53 ]) {
54 const installDir = path.join(baseDir, "tools", name!, version!);
55 const entryPath = path.join(installDir, "node_modules", name!, entry!);
56 yield* fs.makeDirectory(path.dirname(entryPath), { recursive: true });
57 yield* fs.writeFileString(entryPath, "");
58 yield* fs.writeFileString(path.join(installDir, ".install-complete"), version!);
59 }
60 const host = yield* LocalDeviceHost.make().pipe(
61 Effect.provide(Layer.mergeAll(ServerConfig.layerTest(baseDir, baseDir), NetService.layer)),
62 Effect.provideService(HostProcess.Environment, { HOME: baseDir, PATH: "" }),
63 Effect.provideService(HostProcess.IsExecutable, false),
64 Effect.provideService(HostProcess.Platform, "darwin"),
65 Effect.provideService(
66 ChildProcessSpawner.ChildProcessSpawner,
67 ChildProcessSpawner.make(() =>
68 hub.spawnFails
69 ? Effect.fail(
70 PlatformError.systemError({
71 _tag: "NotFound",
72 module: "ChildProcess",
73 method: "spawn",
74 description: "Hub entry missing",
75 }),
76 )
77 : Effect.succeed(
78 ChildProcessSpawner.makeHandle({
79 pid: ChildProcessSpawner.ProcessId(123),
80 stdout: Stream.empty,
81 stderr: Stream.empty,
82 all: Stream.empty,
83 exitCode: Effect.never,
84 isRunning: Effect.sync(() => hub.running),
85 kill: () => Effect.void,
86 stdin: Sink.drain,
87 getInputFd: () => Sink.drain,
88 getOutputFd: () => Stream.empty,
89 unref: Effect.succeed(Effect.void),
90 }),
91 ),
92 ),
93 ),
94 Effect.provideService(ProcessRunner.ProcessRunner, {
95 run: (input) =>
96 input.args.includes("devices")
97 ? startup(stateDir)
98 : Effect.succeed(input.args.includes("-list-avds") ? avdOutput : processOutput(0)),
99 }),
100 Effect.provideService(
101 HttpClient.HttpClient,
102 HttpClient.make((request) =>
103 Ref.get(daemonHealthy).pipe(
104 Effect.map((healthy) =>
105 HttpClientResponse.fromWeb(
106 request,
107 new Response("ok", {
108 status: request.url.endsWith("/health") && !healthy ? 503 : 200,
109 }),
110 ),
111 ),
112 ),
113 ),
114 ),
115 );
116 yield* host.ensureReady(() => Effect.void);
117 return { host, fs, stateDir, hub, daemonHealthy };
118});
119​
120describe("AgentDevice startup", () => {
121 it.effect("restarts a cached daemon that no longer answers its health check", () =>
122 Effect.gen(function* () {
123 const fs = yield* FileSystem.FileSystem;
124 let attempts = 0;
125 const { host, daemonHealthy } = yield* agentFixture((stateDir) =>
126 Effect.gen(function* () {
127 attempts++;
128 yield* fs
129 .writeFileString(
130 `${stateDir}/daemon.json`,
131 JSON.stringify({ httpPort: 12345 + attempts, token: `token-${attempts}` }),
132 )
133 .pipe(Effect.orDie);
134 return processOutput(0);
135 }),
136 );
137 const first = yield* host.ensureAgentReady(() => Effect.void);
138 expect((yield* host.ensureAgentReady(() => Effect.void)).agentDevice).toEqual(
139 first.agentDevice,
140 );
141 expect(attempts).toBe(1);
142​
143 yield* Ref.set(daemonHealthy, false);
144 const restarted = yield* host.ensureAgentReady(() => Effect.void);
145 expect(attempts).toBe(2);
146 expect(restarted.agentDevice).toMatchObject({
147 baseUrl: "http://127.0.0.1:12347",
148 token: "token-2",
149 });
150 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
151 );
152​
153 it.effect("reports an incompatible lock immediately and retains it for manual repair", () =>
154 Effect.gen(function* () {
155 const result = processOutput(
156 1,
157 JSON.stringify({
158 success: false,
159 error: {
160 message: "private command output",
161 details: {
162 reason: "daemon_registration_unproven",
163 inspection: { state: "unproven", reason: "non-directory" },
164 },
165 },
166 }),
167 );
168 const { host, fs, stateDir } = yield* agentFixture(() => Effect.succeed(result));
169 const lock = `${stateDir}/daemon.lock`;
170 const legacyOwner = JSON.stringify({ pid: 85669, processStartTime: "old start time" });
171 yield* fs.writeFileString(lock, legacyOwner);
172 const error = yield* host.ensureAgentReady(() => Effect.void).pipe(Effect.flip);
173 expect(error).toMatchObject({
174 _tag: "AgentDeviceStartError",
175 reason: "daemon_lock_not_directory",
176 exitCode: 1,
177 cause: result,
178 });
179 expect(error.message).toContain("Daemon registration ownership could not be verified");
180 expect(error.message).toContain("daemon.lock is not a directory");
181 expect(error.message).toContain(stateDir);
182 expect(error.message).toContain("original CLI");
183 expect(error.message).not.toContain("private command output");
184 expect(yield* fs.readFileString(lock)).toBe(legacyOwner);
185 expect(yield* host.current).not.toBeNull();
186 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
187 );
188​
189 it.effect("reports unknown nonzero exits without exposing arbitrary command output", () =>
190 Effect.gen(function* () {
191 const result = processOutput(2, "invalid JSON", "private credentials");
192 const { host, stateDir } = yield* agentFixture(() => Effect.succeed(result));
193 const error = yield* host.ensureAgentReady(() => Effect.void).pipe(Effect.flip);
194 expect(error).toMatchObject({
195 _tag: "AgentDeviceStartError",
196 reason: "command_failed",
197 exitCode: 2,
198 cause: result,
199 });
200 expect(error.message).toContain("exit code 2");
201 expect(error.message).toContain(stateDir);
202 expect(error.message).not.toContain("private credentials");
203 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
204 );
205​
206 it.effect("preserves process execution failures instead of waiting for a daemon file", () =>
207 Effect.gen(function* () {
208 const cause = new ProcessRunner.ProcessSpawnError({
209 command: "/missing/node",
210 argumentCount: 3,
211 cause: new Error("missing executable"),
212 });
213 const { host } = yield* agentFixture(() => Effect.fail(cause));
214 const error = yield* host.ensureAgentReady(() => Effect.void).pipe(Effect.flip);
215 expect(error).toMatchObject({
216 _tag: "DeviceHostError",
217 step: "starting agent tools",
218 cause,
219 });
220 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
221 );
222​
223 it.effect("uses a registered daemon when reading startup command output fails", () =>
224 Effect.gen(function* () {
225 const fs = yield* FileSystem.FileSystem;
226 const cause = new ProcessRunner.ProcessReadError({
227 command: process.execPath,
228 argumentCount: 3,
229 stream: "stdout",
230 cause: new Error("output read failed after registration"),
231 });
232 let attempts = 0;
233 const { host } = yield* agentFixture((stateDir) =>
234 Effect.gen(function* () {
235 attempts++;
236 yield* fs
237 .writeFileString(
238 `${stateDir}/daemon.json`,
239 JSON.stringify({ httpPort: 12345, token: "test-token" }),
240 )
241 .pipe(Effect.orDie);
242 return yield* cause;
243 }),
244 );
245 const ready = yield* host.ensureAgentReady(() => Effect.void);
246 expect(ready.agentDevice).toMatchObject({
247 baseUrl: "http://127.0.0.1:12345",
248 token: "test-token",
249 });
250 expect((yield* host.ensureAgentReady(() => Effect.void)).agentDevice).toEqual(
251 ready.agentDevice,
252 );
253 expect((yield* host.current)?.releaseAgentSession).toBeTypeOf("function");
254 expect(attempts).toBe(1);
255 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
256 );
257​
258 it.effect("keeps releasing agent sessions while a dead hub fails to restart and after", () =>
259 Effect.gen(function* () {
260 const fs = yield* FileSystem.FileSystem;
261 const { host, hub } = yield* agentFixture((stateDir) =>
262 fs
263 .writeFileString(
264 `${stateDir}/daemon.json`,
265 JSON.stringify({ httpPort: 12345, token: "test-token" }),
266 )
267 .pipe(Effect.orDie, Effect.as(processOutput(0))),
268 );
269 yield* host.ensureAgentReady(() => Effect.void);
270 hub.running = false;
271 hub.spawnFails = true;
272 expect((yield* host.ensureReady(() => Effect.void).pipe(Effect.result))._tag).toBe("Failure");
273 expect((yield* host.current)?.releaseAgentSession).toBeTypeOf("function");
274 hub.spawnFails = false;
275 yield* host.ensureReady(() => Effect.void);
276 expect((yield* host.current)?.releaseAgentSession).toBeTypeOf("function");
277 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
278 );
279});
280​
281const diagnose = (
282 files: ReadonlyArray<string>,
283 environment: NodeJS.ProcessEnv,
284 platform: NodeJS.Platform = "darwin",
285) =>
286 LocalDeviceHost.__testing.platformReason("android").pipe(
287 Effect.provideService(HostProcess.Environment, environment),
288 Effect.provideService(HostProcess.Platform, platform),
289 Effect.provideService(
290 FileSystem.FileSystem,
291 FileSystem.makeNoop({
292 exists: (file) => Effect.succeed(files.includes(file)),
293 }),
294 ),
295 Effect.provide(platform === "win32" ? NodePath.layerWin32 : NodePath.layerPosix),
296 );
297​
298describe("Android SDK availability", () => {
299 it.effect("uses the standard Windows SDK without probing PATH", () =>
300 Effect.gen(function* () {
301 const root = "C:\\Users\\test\\AppData\\Local\\Android\\Sdk";
302 const probes: string[] = [];
303 const sdk = yield* LocalDeviceHost.__testing.androidSdk.pipe(
304 Effect.provideService(HostProcess.Environment, {
305 USERPROFILE: "C:\\Users\\test",
306 LOCALAPPDATA: "C:\\Users\\test\\AppData\\Local",
307 PATH: "\\\\slow-share\\tools;C:\\other-tools",
308 }),
309 Effect.provideService(HostProcess.Platform, "win32"),
310 Effect.provideService(
311 FileSystem.FileSystem,
312 FileSystem.makeNoop({
313 exists: (file) =>
314 Effect.sync(() => {
315 probes.push(file);
316 return file === `${root}\\platform-tools\\adb.exe`;
317 }),
318 realPath: () => Effect.die("Standard SDK must not resolve PATH executables"),
319 }),
320 ),
321 Effect.provide(NodePath.layerWin32),
322 );
323 expect(sdk).toMatchObject({ root, adb: true });
324 expect(probes.filter((file) => !file.startsWith("C:\\Users\\test\\"))).toEqual([]);
325 }),
326 );
327​
328 it.effect("falls back to adb on the Windows Path without resolving missing entries", () =>
329 Effect.gen(function* () {
330 const root = "D:\\Android\\Sdk";
331 const resolved: string[] = [];
332 const sdk = yield* LocalDeviceHost.__testing.androidSdk.pipe(
333 Effect.provideService(HostProcess.Environment, {
334 USERPROFILE: "C:\\Users\\test",
335 Path: "C:\\missing;C:\\shims",
336 }),
337 Effect.provideService(HostProcess.Platform, "win32"),
338 Effect.provideService(
339 FileSystem.FileSystem,
340 FileSystem.makeNoop({
341 exists: (file) =>
342 Effect.succeed(
343 file === "C:\\shims\\adb.exe" || file === `${root}\\platform-tools\\adb.exe`,
344 ),
345 realPath: (file) =>
346 Effect.sync(() => {
347 resolved.push(file);
348 return `${root}\\platform-tools\\adb.exe`;
349 }),
350 }),
351 ),
352 Effect.provide(NodePath.layerWin32),
353 );
354 expect(sdk).toMatchObject({ root, adb: true });
355 expect(resolved).toEqual(["C:\\shims\\adb.exe"]);
356 }),
357 );
358​
359 // regression: #12017 detect unsupported legacy Android command-line tools
360 it.effect("explains how to upgrade legacy command-line tools in the standard macOS SDK", () =>
361 Effect.gen(function* () {
362 const root = "/test/home/Library/Android/sdk";
363 const reason = yield* diagnose(
364 [`${root}/platform-tools/adb`, `${root}/emulator/emulator`, `${root}/tools/bin/avdmanager`],
365 { HOME: "/test/home" },
366 );
367 expect(reason).toContain("older, unsupported version");
368 expect(reason).toContain(root);
369 expect(reason).toContain(
370 "Install Android SDK Command-line Tools (latest) in Android Studio's SDK Manager under SDK Tools.",
371 );
372 }),
373 );
374​
375 it.effect("accepts the latest command-line tools when legacy tools are also installed", () =>
376 Effect.gen(function* () {
377 const reason = yield* diagnose(
378 [
379 "/sdk/platform-tools/adb",
380 "/sdk/emulator/emulator",
381 "/sdk/tools/bin/avdmanager",
382 "/sdk/cmdline-tools/latest/bin/avdmanager",
383 ],
384 { ANDROID_HOME: "/sdk" },
385 );
386 expect(reason).toBeNull();
387 }),
388 );
389​
390 it.effect("discovers the standard macOS SDK without ANDROID_HOME", () =>
391 Effect.gen(function* () {
392 const root = "/test/home/Library/Android/sdk";
393 const reason = yield* diagnose(
394 [
395 `${root}/platform-tools/adb`,
396 `${root}/emulator/emulator`,
397 `${root}/cmdline-tools/latest/bin/avdmanager`,
398 ],
399 { HOME: "/test/home" },
400 );
401 expect(reason).toBeNull();
402 }),
403 );
404});
405​
406it.effect(
407 "recovers an owned Linux runtime directory without overriding explicit environments",
408 () =>
409 Effect.gen(function* () {
410 const fs = yield* FileSystem.FileSystem;
411 const directory = yield* fs.makeTempDirectoryScoped();
412 const stat = yield* fs.stat(directory);
413 for (const [platform, uid, runtimeDir, type, owner, expected] of [
414 ["linux", 1000, undefined, "Directory", 1000, "/run/user/1000"],
415 ["linux", 1000, "/custom/runtime", "Directory", 1000, "/custom/runtime"],
416 ["linux", 1000, "", "Directory", 1000, ""],
417 ["linux", 1000, undefined, "Directory", 1001, undefined],
418 ["linux", 1000, undefined, "File", 1000, undefined],
419 ["linux", undefined, undefined, "Directory", 1000, undefined],
420 ["darwin", 1000, undefined, "Directory", 1000, undefined],
421 ["win32", 1000, undefined, "Directory", 1000, undefined],
422 ] as const) {
423 const environment = { PATH: "/usr/bin", XDG_RUNTIME_DIR: runtimeDir };
424 const result = yield* LocalDeviceHost.__testing.hubEnvironment(environment).pipe(
425 Effect.provideService(HostProcess.Platform, platform),
426 Effect.provideService(HostProcess.UserId, uid),
427 Effect.provideService(
428 FileSystem.FileSystem,
429 FileSystem.makeNoop({
430 stat: (path) => {
431 expect(path).toBe("/run/user/1000");
432 return Effect.succeed({ ...stat, type, uid: Option.some(owner) });
433 },
434 }),
435 ),
436 );
437 expect(result.XDG_RUNTIME_DIR).toBe(expected);
438 expect(result.PATH).toBe("/usr/bin");
439 expect(result.FORCE_COLOR).toBe("0");
440 expect(result.NO_COLOR).toBe("1");
441 expect(environment.XDG_RUNTIME_DIR).toBe(runtimeDir);
442 }
443 const missing = yield* LocalDeviceHost.__testing
444 .hubEnvironment({})
445 .pipe(
446 Effect.provideService(HostProcess.Platform, "linux"),
447 Effect.provideService(HostProcess.UserId, 1000),
448 Effect.provideService(FileSystem.FileSystem, FileSystem.makeNoop({})),
449 );
450 expect(missing.XDG_RUNTIME_DIR).toBeUndefined();
451 }).pipe(
452 Effect.scoped,
453 Effect.provide(Layer.provideMerge(ProcessRunner.layer, NodeServices.layer)),
454 ),
455);
456​
457it.effect.each([
458 {
459 name: "old SDK",
460 front: "emulated webcam<N> none",
461 back: "emulated virtualscene none",
462 code: 0,
463 extra: undefined,
464 expected: "-camera-front emulated -camera-back emulated",
465 },
466 {
467 name: "imagefile-capable SDK",
468 front: "emulated imagefile:<path> none",
469 back: "emulated imagefile:<path> none",
470 code: 0,
471 extra: undefined,
472 expected: undefined,
473 },
474 {
475 name: "user overrides",
476 front: "emulated none",
477 back: "emulated none",
478 code: 0,
479 extra: "-memory 4096 -camera-front none",
480 expected: "-camera-front emulated -camera-back emulated -memory 4096 -camera-front none",
481 },
482 {
483 name: "different camera capabilities",
484 front: "emulated none",
485 back: "emulated imagefile:<path> none",
486 code: 0,
487 extra: undefined,
488 expected: "-camera-front emulated",
489 },
490 {
491 name: "failed help probe",
492 front: "emulated none",
493 back: "emulated none",
494 code: 1,
495 extra: undefined,
496 expected: undefined,
497 },
498])("configures supported emulator cameras for $name", ({ front, back, code, extra, expected }) =>
499 Effect.gen(function* () {
500 const result = yield* LocalDeviceHost.__testing
501 .hubEnvironment({ ANDROID_HOME: "/sdk", EXPO_DEVICE_HUB_EMULATOR_EXTRA_ARGS: extra })
502 .pipe(
503 Effect.provideService(HostProcess.Platform, "darwin"),
504 Effect.provideService(HostProcess.UserId, 1000),
505 Effect.provideService(ProcessRunner.ProcessRunner, {
506 run: (input) => {
507 expect(input.command).toBe("/sdk/emulator/emulator");
508 expect(input.args[0]).toMatch(/^-help-camera-(front|back)$/);
509 return Effect.succeed(
510 processOutput(code, input.args[0] === "-help-camera-front" ? front : back),
511 );
512 },
513 }),
514 Effect.provide(NodeServices.layer),
515 );
516 expect(result.EXPO_DEVICE_HUB_EMULATOR_EXTRA_ARGS).toBe(expected);
517 }),
518);
519​
520it.effect("keeps local Android and iOS available without ffmpeg", () =>
521 Effect.gen(function* () {
522 const fs = yield* FileSystem.FileSystem;
523 const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-device-ffmpeg-" });
524 yield* fs.makeDirectory(`${baseDir}/bin`);
525 yield* fs.writeFileString(`${baseDir}/bin/xcrun`, "#!/bin/sh\nexit 0\n");
526 yield* fs.chmod(`${baseDir}/bin/xcrun`, 0o755);
527 for (const [directory, tool] of [
528 ["platform-tools", "adb"],
529 ["emulator", "emulator"],
530 ["cmdline-tools/latest/bin", "avdmanager"],
531 ]) {
532 yield* fs.makeDirectory(`${baseDir}/sdk/${directory}`, { recursive: true });
533 yield* fs.writeFileString(`${baseDir}/sdk/${directory}/${tool}`, "");
534 }
535 const onTestHost = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
536 effect.pipe(
537 Effect.provideService(HostProcess.Environment, {
538 HOME: baseDir,
539 PATH: `${baseDir}/bin`,
540 ANDROID_HOME: `${baseDir}/sdk`,
541 }),
542 Effect.provideService(HostProcess.Platform, "darwin"),
543 );
544 const host = yield* LocalDeviceHost.make().pipe(
545 Effect.provide(Layer.mergeAll(ServerConfig.layerTest(baseDir, baseDir), NetService.layer)),
546 onTestHost,
547 Effect.provideService(
548 HttpClient.HttpClient,
549 HttpClient.make(() => Effect.die(new Error("Readiness must not make network requests"))),
550 ),
551 Effect.provideService(ProcessRunner.ProcessRunner, {
552 run: () => Effect.die("Platform availability must not probe emulator video"),
553 }),
554 );
555 expect((yield* onTestHost(host.summary)).platforms).toEqual([
556 { platform: "ios", available: true },
557 { platform: "android", available: true },
558 ]);
559 expect(yield* onTestHost(host.platformAvailability("android"))).toEqual({
560 platform: "android",
561 available: true,
562 });
563 expect(yield* onTestHost(host.platformAvailability("ios"))).toEqual({
564 platform: "ios",
565 available: true,
566 });
567 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
568);
569​
570it.effect(
571 "constructs and inspects an unconfigured host without installing or starting helpers",
572 () =>
573 Effect.gen(function* () {
574 const fs = yield* FileSystem.FileSystem;
575 const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-device-consent-" });
576 const host = yield* LocalDeviceHost.make().pipe(
577 Effect.provide(Layer.mergeAll(ServerConfig.layerTest(baseDir, baseDir), NetService.layer)),
578 Effect.provideService(HostProcess.Environment, { HOME: baseDir, PATH: "" }),
579 Effect.provideService(HostProcess.Platform, "linux"),
580 Effect.provideService(
581 ChildProcessSpawner.ChildProcessSpawner,
582 ChildProcessSpawner.make(() =>
583 Effect.die(new Error("Host construction must not spawn processes")),
584 ),
585 ),
586 Effect.provideService(ProcessRunner.ProcessRunner, {
587 run: () => Effect.die(new Error("Host construction must not run commands")),
588 }),
589 Effect.provideService(
590 HttpClient.HttpClient,
591 HttpClient.make(() =>
592 Effect.die(new Error("Host construction must not make network requests")),
593 ),
594 ),
595 );
596 expect(yield* host.current).toBeNull();
597 const error = yield* host
598 .ensureReady(() => Effect.die("Must not install without Node"))
599 .pipe(Effect.flip, Effect.provideService(HostProcess.IsExecutable, true));
600 expect(error.message).toContain("Local device support requires Node.js");
601 expect(error.message).toContain("Install Node.js");
602 yield* host.stop;
603 expect(yield* fs.exists(`${baseDir}/tools`)).toBe(false);
604 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
605);