Where does the bug appear (feature/product)?
Cursor IDE: Agents window (local agents running in git worktrees)
Describe the Bug
Sometimes Cursor deletes a local agent’s git worktree while that agent’s workbench and its local extension host are still alive. This happened when archiving the agent, when moving it to the cloud, and when Cursor’s own GitProvider.pruneStaleWorktrees removed the .git\worktrees\<id> gitdir. After that, the extension host is never disposed. One of its threads spins indefinitely at about 0.5-0.9 of a core.
The Cursor main process spins about one more core with the same fingerprint. It holds 17 directory-watch handles that resolve to C:\$Extend\$Deleted\..., meaning the directories are pending deletion.
On my machine, 3 zombie extension hosts plus the main process used about 3.8 cores, roughly 19% of a 20-thread CPU, for about 11 hours. Only a full restart stopped it.
Measured on a zombie extension host (Cursor.exe --type=utility --utility-sub-type=node.mojom.NodeService):
- 500k+ “other” (non-read/write) I/O operations per 10 s, about 80% kernel time. Healthy hosts do 1-3k per 10 s.
- One hot thread. Handle count stays flat, so this is a spin, not a leak.
What the logs show:
- Each zombie host maps (through
exthost.log) to a worktree that no longer exists. The worktree folder and its.git\worktrees\<id>are both gone. - The renderer logged
[Worktree] Removing worktree at ...for them. For two of them,git worktree remove --forceactually failed (validation failed ... .git does not exist/Permission denied), yet Cursor logged success. The same removal was also issued from several workbenches, the zombie ones included. - One spin started 87 ms after Cursor’s own
git worktree prune (GitProvider.pruneStaleWorktrees)deleted the gitdir of a worktree whose workbench was still open. - A sibling worktree removed at the same time got
Scheduled service disposaland was disposed 30 s later. The zombie ones never got a disposal line.
Root cause (libuv, Windows):
- Up to libuv 1.52.x, a watched directory that becomes delete-pending makes
ReadDirectoryChangesWfail withERROR_ACCESS_DENIED. - libuv then emits
renameand immediately re-queues the read, which fails again at once. This repeats until the app closes the watcher. - libuv 1.53.0 fixes it (libuv/libuv#5013). Node has not picked it up yet (nodejs/node#66282, tracking nodejs/node#61398).
- Even with that fix, the app still has to close the watcher and dispose the workbench.
Minimal repro of the loop (plain Node v24.5.0 / libuv 1.51.0 on the same machine):
const fs = require('fs'), os = require('os'), path = require('path');
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'watch-repro-'));
let n = 0;
const w = fs.watch(dir, () => n++);
setTimeout(() => {
fs.rmdirSync(dir);
const t = process.cpuUsage(), s = Date.now(), n0 = n;
setTimeout(() => {
const c = process.cpuUsage(t), ms = Date.now() - s;
console.log({ eventsPerSec: Math.round((n - n0) * 1000 / ms), cores: ((c.user + c.system) / 1000 / ms).toFixed(2) });
w.close();
}, 2000);
}, 300);
Output: { eventsPerSec: 155398, cores: '0.97' }. Every event is a rename that carries the full \\?\C:\... path.
Steps to Reproduce
- On Windows, in the Agents window, start a local agent that runs in a worktree.
- While its workbench/tab is still open, archive the agent or move it to the cloud. Alternatively, let
pruneStaleWorktreesremove its gitdir. - In Task Manager or Process Explorer, the agent’s extension host (
Cursor.exe --type=utility ... NodeService) stays alive and pegs about one core. The main process may peg another.
Expected Behavior
- Before deleting or pruning a worktree, dispose the agent’s workbench and extension host and close every file watcher on the worktree and its gitdir.
- Close a watcher when its own root gets
renameor an error. - Do not prune a gitdir that an open workbench is still watching.
- Do not report a worktree removal as successful when git failed.
Operating System
Windows 11 Pro 25H2 (build 26200)
Version Information
Cursor 3.24.12. Update 3.24.18 had been downloaded but was not installed when this was observed, so whether 3.24.18 behaves differently is untested.
Additional Information
Related, but not the same root cause: forum topics 168643 (Windows extension host burning CPU while idle) and 155821 (orphaned extension hosts after window close).
Does this stop you from using Cursor?
No. Cursor works, but it silently burns several cores until it is restarted.