Use native realpathSync instead of spawning subprocess per file

The previous implementation spawned a subprocess for every file during
indexing (e.g., 4500 subprocess spawns for a large collection). This
caused resource exhaustion and random hangs. Using Node's native
realpathSync is orders of magnitude faster.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Burke Libbey 2026-01-04 10:52:31 -05:00
parent c85889df12
commit cfc5ebd553

View File

@ -13,6 +13,7 @@
import { Database } from "bun:sqlite";
import { Glob } from "bun";
import { realpathSync } from "node:fs";
import * as sqliteVec from "sqlite-vec";
import {
LlamaCpp,
@ -116,12 +117,10 @@ export function getPwd(): string {
export function getRealPath(path: string): string {
try {
const result = Bun.spawnSync(["realpath", path]);
if (result.success) {
return result.stdout.toString().trim();
}
} catch {}
return resolve(path);
return realpathSync(path);
} catch {
return resolve(path);
}
}
// =============================================================================