fix: actually enforce the max entries during index construction (#1383)

This commit is contained in:
Kian Jones
2026-03-13 15:07:12 -07:00
committed by GitHub
parent 79fd896b62
commit 50e961ed27

View File

@@ -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) {