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

Function isDaemonReachable

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

Source from the content-addressed store, hash-verified

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