From b0ce01d008bdfb587be7662f8f37768461eaa959 Mon Sep 17 00:00:00 2001 From: Tony Nekola Date: Wed, 24 Dec 2025 23:34:44 +0200 Subject: [PATCH] refactor: use sequential processing for directory file diffs Address PR review feedback: replace Promise.all with sequential for...of loop to avoid exhausting file descriptors when processing directories with many files. --- libs/git-utils/src/diff.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/git-utils/src/diff.ts b/libs/git-utils/src/diff.ts index c88b2f16..30db32da 100644 --- a/libs/git-utils/src/diff.ts +++ b/libs/git-utils/src/diff.ts @@ -77,10 +77,12 @@ Binary file ${cleanPath} added // Empty directory return createNewFileDiff(cleanPath, '040000', ['[Empty directory]']); } - // Generate diffs for all files in the directory - const diffs = await Promise.all( - filesInDir.map((filePath) => generateSyntheticDiffForNewFile(basePath, filePath)) - ); + // Generate diffs for all files in the directory sequentially + // Using sequential processing to avoid exhausting file descriptors on large directories + const diffs: string[] = []; + for (const filePath of filesInDir) { + diffs.push(await generateSyntheticDiffForNewFile(basePath, filePath)); + } return diffs.join(''); }