From 50e961ed272edd7cbe13df0065dedad8ee4452b4 Mon Sep 17 00:00:00 2001 From: Kian Jones <11655409+kianjones9@users.noreply.github.com> Date: Fri, 13 Mar 2026 15:07:12 -0700 Subject: [PATCH] fix: actually enforce the max entries during index construction (#1383) --- src/cli/helpers/fileIndex.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cli/helpers/fileIndex.ts b/src/cli/helpers/fileIndex.ts index 52f7bc3..7d3081a 100644 --- a/src/cli/helpers/fileIndex.ts +++ b/src/cli/helpers/fileIndex.ts @@ -392,7 +392,7 @@ async function buildDirectory( statsMap[relativePath] = currentStats; - if (depth >= MAX_INDEX_DEPTH) { + if (depth >= MAX_INDEX_DEPTH || context.newEntryCount >= MAX_CACHE_ENTRIES) { context.truncated = true; const truncatedHash = hashValue("__truncated__"); merkle[relativePath] = truncatedHash; @@ -402,6 +402,11 @@ async function buildDirectory( const childHashes: string[] = []; for (const entry of childNames) { + if (context.newEntryCount >= MAX_CACHE_ENTRIES) { + context.truncated = true; + break; + } + // Yield to the event loop every 500 entries to keep the UI responsive // during the initial walk of large workspaces. if (context.newEntryCount > 0 && context.newEntryCount % 500 === 0) {