From f45089ccce687f4e5431f87c56d35d4f4eccd02d Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Mon, 29 Jun 2026 01:53:47 +0300 Subject: [PATCH] fix(git): don't log an error when status is requested for a deleted directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getStatus() screamed 'Failed to get Git status' and rethrew for a directory that no longer exists — a benign case hit when PR-status resolution touches a worktree that was deleted while still being watched. Treat a missing directory like a non-repo: skip the error log (callers already handle/​swallow it). --- packages/web/server/lib/git/service.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/web/server/lib/git/service.js b/packages/web/server/lib/git/service.js index 007b4671..4b738b00 100644 --- a/packages/web/server/lib/git/service.js +++ b/packages/web/server/lib/git/service.js @@ -824,6 +824,19 @@ const isNotGitRepositoryError = (error) => { return /not a git repository/i.test(text); }; +// A directory that no longer exists (e.g. a worktree deleted while something +// was still polling its status) is an expected, benign condition — not a fault +// to scream about. simple-git throws "Cannot use simple-git on a directory that +// does not exist"; the underlying fs errors are ENOENT/ENOTDIR. +const isMissingDirectoryError = (error) => { + const code = error?.code; + if (code === 'ENOENT' || code === 'ENOTDIR') { + return true; + } + const text = parseGitErrorText(error); + return /directory that does not exist|does not exist|no such file or directory/i.test(text); +}; + const runGitCommand = async (cwd, args) => { try { const { stdout, stderr } = await execFileAsync(getGitBinary(), args, { @@ -2184,7 +2197,7 @@ export async function getStatus(directory, options = {}) { rebaseInProgress, }; } catch (error) { - if (!isNotGitRepositoryError(error)) { + if (!isNotGitRepositoryError(error) && !isMissingDirectoryError(error)) { console.error('Failed to get Git status:', error); } throw error;