* Heal a long-lived connection whose `.codegraph/` was removed and recreated * at the same path (a worktree recreated, or `rm -rf .codegraph` + re-init) * before handing it to a tool. Otherwise the daemon keeps serving the * pre-removal snapshot from its now-unlinked file handle until resta
(cg: CodeGraph)
| 2435 | * tool call. |
| 2436 | */ |
| 2437 | private freshen(cg: CodeGraph): CodeGraph { |
| 2438 | try { |
| 2439 | if (cg.reopenIfReplaced()) { |
| 2440 | process.stderr.write( |
| 2441 | '[CodeGraph MCP] The index was replaced on disk (e.g. a git worktree ' + |
| 2442 | 'recreated at the same path); reopened the live database in place.\n' |
| 2443 | ); |
| 2444 | this.onDatabaseReopened?.(cg); |
| 2445 | } |
| 2446 | } catch { |
| 2447 | // Best-effort self-heal — a failed reopen must never break the tool call; |
| 2448 | // the (still stale) handle keeps serving and the next call retries. |
| 2449 | } |
| 2450 | return cg; |
| 2451 | } |
| 2452 | |
| 2453 | /** |
| 2454 | * Close all cached project connections |
no test coverage detected