Skip to content

Commit 6a793f2

Browse files
committed
Add overlap detection and cache miss debugging
1 parent 95af6ef commit 6a793f2

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

scripts/generate-md-exports.mjs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,18 @@ async function createWork() {
220220
console.log(` - Files to delete: ${filesToDelete.length}`);
221221

222222
// Debug: Show a few examples of what we're comparing
223-
console.log(
224-
` - Example used files: ${Array.from(globalUsedCacheFiles).slice(0, 3).join(', ')}`
225-
);
223+
const usedArray = Array.from(globalUsedCacheFiles);
224+
console.log(` - Example used files: ${usedArray.slice(0, 3).join(', ')}`);
226225
console.log(` - Example dir files: ${allFiles.slice(0, 3).join(', ')}`);
227226
console.log(` - Example to delete: ${filesToDelete.slice(0, 3).join(', ')}`);
228227

228+
// Check if there's ANY overlap
229+
const overlaps = allFiles.filter(file => globalUsedCacheFiles.has(file));
230+
console.log(` - Files that overlap (exist in both): ${overlaps.length}`);
231+
if (overlaps.length > 0) {
232+
console.log(` - Example overlaps: ${overlaps.slice(0, 3).join(', ')}`);
233+
}
234+
229235
if (filesToDelete.length > 0) {
230236
await Promise.all(
231237
filesToDelete.map(file => rm(path.join(CACHE_DIR, file), {force: true}))
@@ -271,6 +277,14 @@ async function genMDFromHTML(source, target, {cacheDir, noCache, usedCacheFiles}
271277
if (err.code !== 'ENOENT') {
272278
console.warn(`Error using cache file ${cacheFile}:`, err);
273279
}
280+
// Log first cache miss to help debug why HTML is changing
281+
if (err.code === 'ENOENT' && !genMDFromHTML._loggedFirstMiss) {
282+
genMDFromHTML._loggedFirstMiss = true;
283+
console.log(`🔍 First cache miss: ${source}`);
284+
console.log(` Looking for cache key: ${cacheKey}`);
285+
console.log(` HTML length: ${leanHTML.length} chars`);
286+
console.log(` First 200 chars: ${leanHTML.substring(0, 200).replace(/\n/g, '\\n')}`);
287+
}
274288
}
275289
}
276290
let baseUrl = DOCS_ORIGIN;

0 commit comments

Comments
 (0)