facebook/docusaurus · error
An error occurred when trying to get the file ${age === 'old
Error message
An error occurred when trying to get the file ${age === 'oldest' ? 'creation' : 'last update'} date from Git What it means
Thrown by getGitCommitInfo() as a wrapper-level catch-all after getFileCommitDate rejects with an error that is neither GitNotFoundError nor FileNotTrackedError. Those two known cases are downgraded to a single logger.warn; any other failure (file-missing, non-zero exit, unexpected output, or a generic git invocation error) is re-thrown wrapped with context indicating whether the build was seeking 'creation' (age=oldest) or 'last update' (age=newest) dates.
Source
Thrown at packages/docusaurus-utils/src/vcs/gitUtils.ts:240
includeAuthor: true,
});
return {timestamp: result.timestamp, author: result.author};
} catch (err) {
// TODO legacy perf issue: do not use exceptions for control flow!
if (err instanceof GitNotFoundError) {
if (!showedGitRequirementError) {
logger.warn('Sorry, the last update options require Git.');
showedGitRequirementError = true;
}
} else if (err instanceof FileNotTrackedError) {
if (!showedFileNotTrackedError) {
logger.warn(
'Cannot infer the update date for some files, as they are not tracked by git.',
);
showedFileNotTrackedError = true;
}
} else {
throw new Error(
`An error occurred when trying to get the file ${
age === 'oldest' ? 'creation' : 'last update'
} date from Git`,
{cause: err},
);
}
return null;
}
}
export async function getGitLastUpdate(
filePath: string,
): Promise<GitCommitInfo | null> {
return getGitCommitInfo(filePath, 'newest');
}
export async function getGitCreation(
filePath: string,View on GitHub (pinned to 3f483e80e3)
Solutions
- Inspect the cause property of the thrown error — it is the underlying Error from getFileCommitDate (errors 94, 95, or 97).
- Apply the fix appropriate to the cause: restore the missing file (94), repair the repo / remove stale locks (95), or address the git output issue (97).
- If you call getGitLastUpdate / getGitCreation directly and want to tolerate transient failures, wrap them in try/catch and fall back to null.
- Re-run the build after resolving the underlying cause.
Example fix
// before — caller propagates the wrapper unconditionally
const info = await getGitLastUpdate(filePath);
// after — caller degrades gracefully when git info is unavailable
let info = null;
try {
info = await getGitLastUpdate(filePath);
} catch (err) {
console.warn(`Skipping git info for ${filePath}: ${err.cause ?? err}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
import fs from 'fs-extra';
async function safeToQueryGit(file: string): Promise<boolean> {
return await fs.pathExists(file);
}
if (!(await safeToQueryGit(file))) return null; Try / catch
try {
await getGitLastUpdate(filePath);
} catch (err) {
// err.cause is the underlying getFileCommitDate error (94/95/97)
console.warn(`Git info unavailable for ${filePath}: ${err.cause ?? err}`);
return null;
} Prevention
- Inspect err.cause — the wrapper hides the real failure behind a generic message.
- Resolve the underlying cause (missing file, corrupted repo, unexpected git output) using errors 94/95/97 guidance.
- If you call getGitLastUpdate / getGitCreation directly, wrap them in try/catch and degrade to null when git info is non-critical.
When it happens
Trigger: Any of errors 94, 95, or 97 bubbling up through getGitCommitInfo — i.e. the file does not exist, git exited non-zero, or the log output was unparseable. Since getGitCommitInfo catches only the two custom error classes, every other throw from getFileCommitDate is wrapped here.
Common situations: Building with showLastUpdateTime while a content file is missing, the repo is corrupted, or git produced unexpected output (see the underlying errors 94/95/97). The wrapper error hides the original behind a generic message, so the cause property must be inspected to find the real failure.
Related errors
- Could not get all the git repository root paths (superprojec
- This Docusaurus site is outside any Git worktree. Unable to
- Processing of blog source file path=${blogSourceFile} failed
- Can't process doc metadata for doc at path path=${args.docFi
- Failed to retrieve the git history for file "${file}" becaus
AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12).
Data as JSON: /api/errors/bdbaf2a3c8bec433.
Report an issue: GitHub.