MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / waitGuestPageTarget

Function waitGuestPageTarget

e2e/setup/desktop-vm.ts:32–45  ·  view source on GitHub ↗
(
  vm: VmHandle,
  port: number,
  attempts = 60,
)

Source from the content-addressed store, hash-verified

30 * is up, not just the browser endpoint. On a cold guest the page appears a good
31 * bit after the port opens, so gating on this makes the scenario deterministic. */
32export const waitGuestPageTarget = async (
33 vm: VmHandle,
34 port: number,
35 attempts = 60,
36): Promise<boolean> => {
37 for (let i = 0; i < attempts; i++) {
38 const r = await vm.ssh(
39 `curl -s --max-time 5 http://127.0.0.1:${port}/json/list 2>/dev/null | grep -c '"type": "page"' || echo 0`,
40 );
41 if (Number(r.stdout.trim() || "0") > 0) return true;
42 await sleep(2000);
43 }
44 return false;
45};
46
47export interface ProvisionedGuest {
48 readonly ip: string;

Callers 2

provisionMacFunction · 0.90
provisionLinuxFunction · 0.90

Calls 2

sshMethod · 0.80
sleepFunction · 0.70

Tested by

no test coverage detected