From cfc5ebd553a2eec6d9d46169f80488e89bb51a03 Mon Sep 17 00:00:00 2001 From: Burke Libbey Date: Sun, 4 Jan 2026 10:52:31 -0500 Subject: [PATCH] Use native realpathSync instead of spawning subprocess per file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/store.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/store.ts b/src/store.ts index ffc8bef..c1fb995 100644 --- a/src/store.ts +++ b/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); + } } // =============================================================================