Repository navigation
VS Code extension sandbox leaves empty .git directory, causing Git discovery CPU spin #28631
Description
Summary
When using the Codex VS Code extension in a non-Git workspace on a Linux remote environment, Codex sandbox setup appears to leave an empty .git directory on the host workspace root. VS Code Git then repeatedly treats the folder as a Git repository candidate and spawns git rev-parse --show-toplevel, causing the VS Code extension host to consume high CPU continuously.
Environment
- VS Code Server: 1.124.2
- Codex VS Code extension:
openai.chatgpt26.609.30741linux-x64 - Platform: Linux remote environment, likely WSL2
- Codex sandbox:
workspace-write/ bubblewrap - Observed affected workspaces:
$HOME/avatra$HOME/tmp/cf
Observed Behavior
-
The workspace is not a Git repository and initially has no valid
.gitdirectory. -
After using Codex in the workspace, an empty host-visible
.gitdirectory appears at the workspace root. -
The directory has no
.git/HEAD. -
VS Code Git repeatedly runs:
git -c core.hooksPath=/dev/null -c core.fsmonitor= rev-parse --show-toplevel -
Git fails with:
fatal: not a git repository (or any of the parent directories): .git -
The VS Code extension host stays at roughly 50-65% CPU.
Evidence
For one affected extension host PID, a 10 second strace sample showed:
- 70,503 syscalls
- 4,256
execvecalls - 304
clonecalls - 611
wait4calls - 211
/usr/bin/gitexecutions in$HOME/tmp/cf
The repeated command was:
git -c core.hooksPath=/dev/null -c core.fsmonitor= rev-parse --show-toplevel
The trace showed:
$HOME/tmp/cf/.gitexists$HOME/tmp/cf/.git/HEADreturnsENOENT
The same pattern was previously observed in another workspace, with 324 git rev-parse executions in 10 seconds.
A Codex sandbox command line also included a mount entry like:
--tmpfs $HOME/tmp/cf/.git --remount-ro
That suggests the sandbox may be creating a host-side mountpoint for .git, then leaving the empty directory behind after sandbox use.
Expected Behavior
Codex sandbox setup should not leave an empty .git directory on the host filesystem for a non-Git workspace. If a private .git mount is needed inside the sandbox, it should not persist as a host-visible directory after the sandbox exits.
Actual Behavior
An empty host-visible .git directory remains. VS Code Git sees it and repeatedly retries Git discovery, causing high CPU in the extension host.
Related Log Noise
The Codex log also repeatedly contains:
Received broadcast but no handler is configured method=thread-stream-state-changed
This may be separate, but strace shows the dominant CPU source is the Git discovery loop caused by the empty .git directory.
Feedback UI Issue
I also attempted to submit this via /feedback. The UI showed no confirmation and no session ID, although the Codex manual says a session ID should be shown after submission.
The local Codex log contains:
codex_app_server::request_processors::feedback_doctor_report: timed out running doctor report for feedback; skipping attachment
So I cannot tell whether the in-product feedback submission actually succeeded.
Workarounds
-
Remove the empty
.gitdirectory withrmdir <workspace>/.git -
Disable Git integration for the affected workspace:
{ "git.enabled": false } -
Reload or restart the VS Code extension host
Activity
hkwi commentedon Jun 17, 2026
Related issues I found after filing:
.gitpath as tmpfs. The difference here is that I observed an empty host-visible.gitdirectory left behind in a non-Git workspace, followed by VS Code Git repeatedly runninggit rev-parse --show-toplevel./usr/bin/gitexecutions in 10 seconds.HEAD, but for an unborn Git repository rather than a host-visible empty.gitdirectory created around sandbox activity.So this may be a cross-product of #26463 and #17394: sandbox leaves or exposes a
.gitpath that makes the IDE Git metadata/discovery loop pathological.nken-eccs commentedon Jul 16, 2026
I can confirm this issue is still present in
openai.chatgpt-26.707.91948-linux-x64.In my case,
$HOMEwas not a Git repository, but$HOME/.gitexisted as a completely empty directory. While Codex was active, the Extension Host repeatedly ran:I observed approximately 750–1,287 executions every 5 seconds.
codex app-serverCPU: only about 2–4%Confirmed loop
Because the empty
.gitdirectory continues to exist, the newly created watcher immediately follows the same path. There is no delay or backoff between attempts.Renaming the empty directory stopped the loop without reloading VS Code or restarting the Extension Host:
In the next measurement window:
rev-parseexecutions dropped to 0Suggested fixes
checkForGitDirectory()should not treat a successfulstat(".git")as completed Git initialization. It should verify that the path resolves to valid Git metadata before disposing the watcher and callingonGitInit().When
handleGitInit()receives null metadata, it should not callensureWatchingForGitInit()immediately. The retry should use a bounded exponential backoff, for example:A negative Git-root result should be cached per host and cwd for the backoff period, so repeated metadata invalidation cannot immediately spawn another
gitprocess.If the sandbox creates
.gitas a host-side mountpoint, it should remove that directory when the sandbox exits if it did not exist before and is still empty.Add a regression test that creates an empty
.gitdirectory in a non-Git cwd and verifies that Git discovery attempts remain bounded.