Skip to content

fix(watcher): store Debouncer in RepoWatcher to prevent OS handle leak#2978

Open
Noethix55555 wants to merge 1 commit into
gitui-org:masterfrom
Noethix55555:fix/watcher-debouncer-leak
Open

fix(watcher): store Debouncer in RepoWatcher to prevent OS handle leak#2978
Noethix55555 wants to merge 1 commit into
gitui-org:masterfrom
Noethix55555:fix/watcher-debouncer-leak

Conversation

@Noethix55555

Copy link
Copy Markdown

Summary

  • create_watcher called std::mem::forget(bouncer) to keep the OS file-watcher handle alive, but this permanently leaks the handle on every call — one leak per submodule repo opened, never cleaned up.
  • Fix: remove create_watcher (and the thread that called it). Create the Debouncer inline in RepoWatcher::new and store it in a new _watcher: Debouncer<RecommendedWatcher> field so the OS handle is properly released when RepoWatcher is dropped.
  • Also removes the now-unused scopetime import.

Test plan

  • Open a repo with submodules and verify file-watching still works
  • Confirm no extra OS handles accumulate (e.g. via lsof/Process Explorer) when opening multiple repos

`create_watcher` called `std::mem::forget(bouncer)` to keep the
file-watcher alive, but this permanently leaked the OS watcher handle
on every call. Each submodule repo opened added another leaked handle
that was never cleaned up.

Fix: remove `create_watcher` and the spawned thread that called it.
Create the debouncer inline in `RepoWatcher::new` and store it in a
new `_watcher` field so the OS handle is released when `RepoWatcher`
is dropped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant