From cb8d6d8724dfb44e7598950b53b2a36beabd0787 Mon Sep 17 00:00:00 2001 From: garrytan-agents Date: Wed, 13 May 2026 21:59:22 -0700 Subject: [PATCH] fix(sync): raise maxBuffer to 100 MiB to prevent silent ENOBUFS crash (#982) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Node's default maxBuffer for execFileSync is 1 MiB. On repos with 60-100K files, `git diff --name-status -M` output easily exceeds this, causing the sync process to die silently with no error in the log. Observed at /data/brain (99K files, 62K in git ls-files): sync consistently died during the rename-detection phase at ~15% through `buildSyncManifest()`. No stack trace, no error event — just a dead process. The fix survived 5+ full syncs on the same corpus. 100 MiB is generous but bounded. A 100K-file diff with long paths tops out around 10-20 MiB in practice. Co-authored-by: garrytan-agents --- src/commands/sync.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/commands/sync.ts b/src/commands/sync.ts index a2c619650..0cc80e646 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -211,10 +211,21 @@ export function buildGitInvocation(repoPath: string, args: string[], configs: st return [...cfg, '-C', repoPath, ...args]; } +/** + * Shell out to git with a generous maxBuffer. + * + * Node's default maxBuffer is 1 MiB. `git diff --name-status -M` on a + * 60–100K file repo easily exceeds that, causing an ENOBUFS crash that + * kills the sync process with no error message in the log. + * + * 100 MiB is generous but still bounded — a 100K-file diff with long + * paths tops out around 10–20 MiB in practice. + */ function git(repoPath: string, args: string[], configs: string[] = []): string { return execFileSync('git', buildGitInvocation(repoPath, args, configs), { encoding: 'utf-8', timeout: 30000, + maxBuffer: 100 * 1024 * 1024, }).trim(); }