* 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)
| 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) |
no test coverage detected