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

Function isDaemonReachable

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

Source from the content-addressed store, hash-verified

397
398/** Probe the unauthenticated Executor health endpoint without disclosing the saved bearer. */
399const isDaemonReachable = async (origin: string): Promise<boolean> => {
400 for (let attempt = 0; attempt < 3; attempt += 1) {
401 const controller = new AbortController();
402 const timer = setTimeout(() => controller.abort(), 1500);
403 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: fetch rejects on a down server; that's the "not reachable" signal
404 try {
405 const response = await fetch(new URL("/api/health", origin), {
406 signal: controller.signal,
407 redirect: "manual",
408 });
409 const body = await response.text();
410 if (response.ok && body.trim() === "ok") return true;
411 } catch {
412 // retry below
413 } finally {
414 clearTimeout(timer);
415 }
416 if (attempt < 2) await delay(150);
417 }
418 return false;
419};
420
421/**
422 * 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