MCPcopy Index your code
hub / github.com/callstack/agent-device / waitForDaemonStartup

Function waitForDaemonStartup

src/daemon/client/daemon-client-lifecycle.ts:359–380  ·  view source on GitHub ↗
(
  timeoutMs: number,
  settings: DaemonClientSettings,
  launch: DaemonStartupLaunch,
)

Source from the content-addressed store, hash-verified

357}
358
359async function waitForDaemonStartup(
360 timeoutMs: number,
361 settings: DaemonClientSettings,
362 launch: DaemonStartupLaunch,
363): Promise<DaemonStartupWaitResult> {
364 const start = Date.now();
365 let earlyExit: ExecDetachedExit | undefined;
366 void launch.exited.then((exit) => {
367 earlyExit = exit;
368 });
369
370 while (Date.now() - start < timeoutMs) {
371 if (earlyExit) return { kind: 'early_exit', exit: earlyExit };
372 const info = readDaemonInfo(settings.paths.infoPath);
373 if (info && (await canConnect(info, settings.transportPreference))) {
374 return { kind: 'ready', info };
375 }
376 if (earlyExit) return { kind: 'early_exit', exit: earlyExit };
377 await sleep(100);
378 }
379 return { kind: 'timeout' };
380}
381
382function startDaemon(settings: DaemonClientSettings): DaemonStartupLaunch {
383 const launchSpec = resolveDaemonLaunchSpec();

Callers 1

startLocalDaemonFunction · 0.85

Calls 3

readDaemonInfoFunction · 0.90
canConnectFunction · 0.90
sleepFunction · 0.90

Tested by

no test coverage detected