Selaa lähdekoodia

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>
Burke Libbey 4 kuukautta sitten
vanhempi
commit
cfc5ebd553
1 muutettua tiedostoa jossa 5 lisäystä ja 6 poistoa
  1. 5 6
      src/store.ts

+ 5 - 6
src/store.ts

@@ -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);
+  }
 }
 
 // =============================================================================