MCPcopy
hub / github.com/colbymchenry/codegraph / retryInitializeSync

Method retryInitializeSync

src/mcp/engine.ts:157–178  ·  view source on GitHub ↗

* Synchronous last-resort init used by the per-session retry loop when the * background `ensureInitialized` already finished (or failed) and we need * to pick up a project that appeared *after* the engine started.

(searchFrom: string)

Source from the content-addressed store, hash-verified

155 * to pick up a project that appeared *after* the engine started.
156 */
157 retryInitializeSync(searchFrom: string): void {
158 if (this.closed) return;
159 if (this.toolHandler.hasDefaultCodeGraph()) return;
160 this.toolHandler.setDefaultProjectHint(searchFrom);
161 const resolvedRoot = findNearestCodeGraphRoot(searchFrom);
162 if (!resolvedRoot) return;
163 try {
164 // Close any previously failed instance to avoid leaking resources.
165 if (this.cg) {
166 try { this.cg.close(); } catch { /* ignore */ }
167 this.cg = null;
168 }
169 this.cg = loadCodeGraph().openSync(resolvedRoot);
170 this.projectPath = resolvedRoot;
171 this.toolHandler.setDefaultCodeGraph(this.cg);
172 this.startWatching();
173 this.catchUpSync();
174 this.maybeStartPool(resolvedRoot);
175 } catch {
176 // Still failing — caller will try again on the next tool call.
177 }
178 }
179
180 /**
181 * Close everything. Used on graceful daemon shutdown (SIGTERM/idle timeout)

Callers 1

retryInitIfNeededMethod · 0.80

Calls 10

startWatchingMethod · 0.95
catchUpSyncMethod · 0.95
maybeStartPoolMethod · 0.95
findNearestCodeGraphRootFunction · 0.90
setDefaultProjectHintMethod · 0.80
openSyncMethod · 0.80
setDefaultCodeGraphMethod · 0.80
loadCodeGraphFunction · 0.70
closeMethod · 0.65
hasDefaultCodeGraphMethod · 0.45

Tested by

no test coverage detected