Repository navigation
fix(git): stop leaking fsmonitor daemons e.g. 60GB+ of commited memory after running tests #16249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f49f323
fix(git): stop leaking fsmonitor daemons
Hona c5c0eba
fix(test): suppress cleanup errors in fixture to avoid masking test f…
Hona 59af5bd
Merge branch 'dev' into fix/git-fsmonitor-cleanup
Hona 73a9c26
fix: use realpath consistently for init/dispose and drop unnecessary …
Hona File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { $ } from "bun" | ||
| import { describe, expect, test } from "bun:test" | ||
| import fs from "fs/promises" | ||
| import path from "path" | ||
| import { File } from "../../src/file" | ||
| import { Instance } from "../../src/project/instance" | ||
| import { tmpdir } from "../fixture/fixture" | ||
|
|
||
| const wintest = process.platform === "win32" ? test : test.skip | ||
|
|
||
| describe("file fsmonitor", () => { | ||
| wintest("status does not start fsmonitor for readonly git checks", async () => { | ||
| await using tmp = await tmpdir({ git: true }) | ||
| const target = path.join(tmp.path, "tracked.txt") | ||
|
|
||
| await fs.writeFile(target, "base\n") | ||
| await $`git add tracked.txt`.cwd(tmp.path).quiet() | ||
| await $`git commit -m init`.cwd(tmp.path).quiet() | ||
| await $`git config core.fsmonitor true`.cwd(tmp.path).quiet() | ||
| await $`git fsmonitor--daemon stop`.cwd(tmp.path).quiet().nothrow() | ||
| await fs.writeFile(target, "next\n") | ||
| await fs.writeFile(path.join(tmp.path, "new.txt"), "new\n") | ||
|
|
||
| const before = await $`git fsmonitor--daemon status`.cwd(tmp.path).quiet().nothrow() | ||
| expect(before.exitCode).not.toBe(0) | ||
|
|
||
| await Instance.provide({ | ||
| directory: tmp.path, | ||
| fn: async () => { | ||
| await File.status() | ||
| }, | ||
| }) | ||
|
|
||
| const after = await $`git fsmonitor--daemon status`.cwd(tmp.path).quiet().nothrow() | ||
| expect(after.exitCode).not.toBe(0) | ||
| }) | ||
|
|
||
| wintest("read does not start fsmonitor for git diffs", async () => { | ||
| await using tmp = await tmpdir({ git: true }) | ||
| const target = path.join(tmp.path, "tracked.txt") | ||
|
|
||
| await fs.writeFile(target, "base\n") | ||
| await $`git add tracked.txt`.cwd(tmp.path).quiet() | ||
| await $`git commit -m init`.cwd(tmp.path).quiet() | ||
| await $`git config core.fsmonitor true`.cwd(tmp.path).quiet() | ||
| await $`git fsmonitor--daemon stop`.cwd(tmp.path).quiet().nothrow() | ||
| await fs.writeFile(target, "next\n") | ||
|
|
||
| const before = await $`git fsmonitor--daemon status`.cwd(tmp.path).quiet().nothrow() | ||
| expect(before.exitCode).not.toBe(0) | ||
|
|
||
| await Instance.provide({ | ||
| directory: tmp.path, | ||
| fn: async () => { | ||
| await File.read("tracked.txt") | ||
| }, | ||
| }) | ||
|
|
||
| const after = await $`git fsmonitor--daemon status`.cwd(tmp.path).quiet().nothrow() | ||
| expect(after.exitCode).not.toBe(0) | ||
| }) | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { $ } from "bun" | ||
| import { describe, expect, test } from "bun:test" | ||
| import fs from "fs/promises" | ||
| import { tmpdir } from "./fixture" | ||
|
|
||
| describe("tmpdir", () => { | ||
| test("disables fsmonitor for git fixtures", async () => { | ||
| await using tmp = await tmpdir({ git: true }) | ||
|
|
||
| const value = (await $`git config core.fsmonitor`.cwd(tmp.path).quiet().text()).trim() | ||
| expect(value).toBe("false") | ||
| }) | ||
|
|
||
| test("removes directories on dispose", async () => { | ||
| const tmp = await tmpdir({ git: true }) | ||
| const dir = tmp.path | ||
|
|
||
| await tmp[Symbol.asyncDispose]() | ||
|
|
||
| const exists = await fs | ||
| .stat(dir) | ||
| .then(() => true) | ||
| .catch(() => false) | ||
| expect(exists).toBe(false) | ||
| }) | ||
| }) |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.