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

Function isDaemonReachable

apps/desktop/src/main/sidecar.ts:376–396  ·  view source on GitHub ↗
(origin: string)

Source from the content-addressed store, hash-verified

374
375/** Probe the unauthenticated Executor health endpoint without disclosing the saved bearer. */
376const isDaemonReachable = async (origin: string): Promise<boolean> => {
377 for (let attempt = 0; attempt < 3; attempt += 1) {
378 const controller = new AbortController();
379 const timer = setTimeout(() => controller.abort(), 1500);
380 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: fetch rejects on a down server; that's the "not reachable" signal
381 try {
382 const response = await fetch(new URL("/api/health", origin), {
383 signal: controller.signal,
384 redirect: "manual",
385 });
386 const body = await response.text();
387 if (response.ok && body.trim() === "ok") return true;
388 } catch {
389 // retry below
390 } finally {
391 clearTimeout(timer);
392 }
393 if (attempt < 2) await delay(150);
394 }
395 return false;
396};
397
398/**
399 * Attach to an already-running OS-supervised daemon instead of spawning our own

Callers

nothing calls this directly

Calls 4

delayFunction · 0.70
abortMethod · 0.65
textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected