| 374 | |
| 375 | /** Probe the unauthenticated Executor health endpoint without disclosing the saved bearer. */ |
| 376 | const 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 |