MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / waitForDaemonReady

Function waitForDaemonReady

src/cli/daemon-control.ts:162–186  ·  view source on GitHub ↗
(opts: WaitForDaemonReadyOptions)

Source from the content-addressed store, hash-verified

160 * Throws if the daemon doesn't respond within the timeout.
161 */
162export async function waitForDaemonReady(opts: WaitForDaemonReadyOptions): Promise<void> {
163 const client = new DaemonClient({
164 socketPath: opts.socketPath,
165 timeout: Math.min(opts.timeoutMs, 2000), // Short timeout for each status check
166 });
167
168 const pollInterval = opts.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
169 const startTime = Date.now();
170
171 while (Date.now() - startTime < opts.timeoutMs) {
172 try {
173 // Use status() to confirm protocol handler is ready (not just connect)
174 await client.status();
175 return; // Success
176 } catch {
177 // Not ready yet, wait and retry
178 await new Promise((resolve) => setTimeout(resolve, pollInterval));
179 }
180 }
181
182 throw new Error(
183 `Daemon failed to start within ${opts.timeoutMs}ms. ` +
184 `Check if another daemon is running or if there are permission issues.`,
185 );
186}
187
188export interface EnsureDaemonRunningOptions {
189 socketPath: string;

Callers 1

ensureDaemonRunningFunction · 0.85

Calls 1

statusMethod · 0.95

Tested by

no test coverage detected