From 6e8239a6e239f1aa87a9e766b9ffbf1941fc1393 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Tue, 23 Sep 2025 21:43:13 +0530 Subject: [PATCH] chore: add debug logging for cache misses in git timestamp retrieval --- src/node/utils/getGitTimestamp.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node/utils/getGitTimestamp.ts b/src/node/utils/getGitTimestamp.ts index 463379b5..fd6d3177 100644 --- a/src/node/utils/getGitTimestamp.ts +++ b/src/node/utils/getGitTimestamp.ts @@ -1,8 +1,10 @@ import { spawn, sync } from 'cross-spawn' +import _debug from 'debug' import fs from 'node:fs' import path from 'node:path' import { slash } from '../shared' +const debug = _debug('vitepress:git') const cache = new Map() const RS = 0x1e @@ -91,9 +93,11 @@ export async function cacheAllGitTimestamps( export async function getGitTimestamp(file: string): Promise { const cached = cache.get(file) - // most likely will never be stale except for recently added files in dev if (cached) return cached + // most likely will never happen except for recently added files in dev + debug(`[cache miss] ${file}`) + if (!fs.existsSync(file)) return 0 return new Promise((resolve, reject) => {