fix(git): stop leaking fsmonitor daemons e.g. 60GB+ of commited memory after running tests#16249
Merged
Hona merged 4 commits intoanomalyco:devfrom Mar 6, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents Git fsmonitor daemons from being spawned/leaked by opencode’s temporary repos, readonly git checks, and worktree cleanup—especially on Windows.
Changes:
- Disable
core.fsmonitorin opencode-owned temp git repos and stop any running daemon before removing git directories. - Force readonly git operations (
status,diff,ls-files,show) to opt out of fsmonitor viagit -c core.fsmonitor=false .... - Add Windows-focused regression tests covering fixture cleanup, readonly git checks, and worktree removal behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/opencode/src/file/index.ts | Opt out of fsmonitor for readonly git diff/status-related commands. |
| packages/opencode/src/worktree/index.ts | Stop fsmonitor daemon before worktree removal; opt out during reset dirty-check. |
| packages/opencode/test/fixture/fixture.ts | Disable fsmonitor in git fixtures; ensure daemon stop + retrying cleanup on dispose. |
| packages/opencode/test/fixture/fixture.test.ts | Regression tests for fsmonitor-disabled fixtures and disposal cleanup. |
| packages/opencode/test/file/fsmonitor.test.ts | Windows-only tests asserting readonly git checks don’t start fsmonitor. |
| packages/opencode/test/project/worktree-remove.test.ts | Adds Windows-only test for stopping fsmonitor before worktree removal. |
| packages/app/e2e/actions.ts | Disable fsmonitor in e2e git repo creation; stop daemon + retrying rm on cleanup. |
Comments suppressed due to low confidence (1)
packages/opencode/test/project/worktree-remove.test.ts:24
- The first test in this file uses Unix-specific tooling (
which git, a#!/bin/bashshim, andchmod) but it is not skipped on Windows. Since this PR adds Windows-specific coverage in the same suite (wintest), running the whole file on Windows will likely fail. Either skip that regression test onwin32, or make the shim cross-platform (e.g.,where git+ agit.cmdwrapper on Windows).
const wintest = process.platform === "win32" ? test : test.skip
describe("Worktree.remove", () => {
test("continues when git remove exits non-zero after detaching", async () => {
await using tmp = await tmpdir({ git: true })
const root = tmp.path
const name = `remove-regression-${Date.now().toString(36)}`
const branch = `opencode/${name}`
const dir = path.join(root, "..", name)
await $`git worktree add --no-checkout -b ${branch} ${dir}`.cwd(root).quiet()
await $`git reset --hard`.cwd(dir).quiet()
const real = (await $`which git`.quiet().text()).trim()
expect(real).toBeTruthy()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…fsmonitor flag on git show
jerome-benoit
pushed a commit
to jerome-benoit/opencode
that referenced
this pull request
Mar 6, 2026
…y after running tests (anomalyco#16249)
qdddddd
pushed a commit
to qdddddd/opencode
that referenced
this pull request
Mar 7, 2026
…y after running tests (anomalyco#16249)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing