MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / awaitCatchUpGate

Method awaitCatchUpGate

src/mcp/tools.ts:890–916  ·  view source on GitHub ↗

* Await the catch-up gate, but no longer than the configured timeout (#905). * If the reconcile settles first, we got the fully-reconciled answer. If the * timeout wins, we serve the call now and let the reconcile finish in the * background — it yields to the event loop (see SYNC_RECONCILE_

(gate: Promise<void>)

Source from the content-addressed store, hash-verified

888 * the same potentially-stale data the un-gated path would have.
889 */
890 private async awaitCatchUpGate(gate: Promise<void>): Promise<void> {
891 const timeoutMs = resolveCatchUpGateTimeoutMs();
892 if (timeoutMs <= 0) {
893 // 0 = opt back into the original unbounded wait.
894 try { await gate; } catch { /* engine already logged */ }
895 return;
896 }
897 let timer: NodeJS.Timeout | undefined;
898 const timedOut = new Promise<'timeout'>((resolve) => {
899 timer = setTimeout(() => resolve('timeout'), timeoutMs);
900 timer.unref?.();
901 });
902 try {
903 const outcome = await Promise.race([
904 gate.then(() => 'done' as const, () => 'done' as const),
905 timedOut,
906 ]);
907 if (outcome === 'timeout') {
908 process.stderr.write(
909 `[CodeGraph MCP] Catch-up reconcile still running after ${timeoutMs}ms; serving this tool call now and finishing the reconcile in the background (#905). ` +
910 `Set CODEGRAPH_CATCHUP_GATE_TIMEOUT_MS=0 to always wait for it.\n`
911 );
912 }
913 } finally {
914 if (timer) clearTimeout(timer);
915 }
916 }
917
918 /**
919 * Record the directory the server tried to resolve the default project from.

Callers 1

executeMethod · 0.95

Calls 3

resolveFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected