[Windows] flashgrep 常驻进程长时间占用文件,导致 Agent 命令执行报“文件被占用”
@wgqqqqq is already working on this.
Since Aug 17, 2026.
Assessment
This issue has not been assessed yet.
Description
现象
在 Windows 上开启工作区搜索(flashgrep)后,Agent 执行某些 shell 命令会随机报“另一个程序正在使用此文件 / 拒绝访问”(Windows 错误 32/5),例如:
git clean -fdx、rm -rf、cargo cleangit checkout/ 分支切换- 安装器/更新器替换
flashgrep.exe
根因分析
flashgrep 以 flashgrep serve --stdio 单例常驻子进程运行,工作区一打开就被拉起,之后整个应用运行期间不退出。由此在 Windows 上产生持续的文件占用:
- 进程常驻:daemon 仅在应用退出(
perform_process_exit_cleanup→shutdown_blocking,src/apps/desktop/src/lib.rs)或关闭“工作区搜索”功能时被停止;工作区打开即被 warmup 拉起(src/apps/desktop/src/api/workspace_activation.rs)。 - 索引放在工作区内:
default_storage_root返回{repo}/.bitfun/search/flashgrep-index(src/crates/services/services-integrations/src/workspace_search/service.rs)。daemon 以 mmap / WAL / segment 方式持有这些索引文件(协议字段active_segments/active_delete_segments/pending_docs佐证)。 - 空闲释放形同虚设:
schedule_repo_release只在“warmup 后工作区已切走”的竞态分支被调用一次,正常search/glob/status流程从不触发;且release_repo_if_idle只发送CloseRepo,不停止 daemon 进程。
在 Windows 上,进程句柄 / 内存映射 / 目录监听句柄会阻止文件被删除、重命名或覆盖,因此 daemon 存活期间索引文件(以及 flashgrep.exe 映像)一直处于被占用状态。
影响
- Agent 的破坏性 / 切换类 shell 命令在 Windows 上随机失败,打断工作流。
- daemon 存活期间无法替换
flashgrep.exe。
可能的优化方向(调研结论,方案待定)
- 空闲时真正释放 repo 会话,并在会话清空后停止 daemon 进程(复用已有的透明重启能力)。
- 把索引移出工作区,放入全局
~/.bitfun/projects/<workspace-slug>/目录(已有sessions/snapshots/plans等按工作区分片的持久化目录)。 - 反馈 / 升级上游
wgqqqqq/flashgrep(当前 v0.2.10),确认 Windows 下是否以FILE_SHARE_DELETE打开文件、CloseRepo是否解除 mmap。
环境
- 平台:Windows
- flashgrep:v0.2.10(
resources/flashgrep/VERSION.json)
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 236
- Avg merge
- 2h 56m
- Merged PRs (30d)
- 619
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GCWing/OpenBitFun
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
GCWing/OpenBitFun#3213 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
GCWing/OpenBitFun#2363 ·
-
question
Difficulty 1/5 Under an hour Newbie friendliness 78/100
GCWing/OpenBitFun#2340 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
GCWing/OpenBitFun#3210 ·
-
GCWing/OpenBitFun#3195 · 2 comments · 1 assignee ·
All issues in GCWing/OpenBitFun
Similar issues
-
bug CLI custom-model
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
rust-bitcoin/rust-bitcoin#6930 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
fulcrumgenomics/ferro-hgvs#2251 ·
-
A-allocators A-docs C-enhancement T-libs
Difficulty 2/5 1-3 hours Newbie friendliness 75/100