rewatch watch on Linux stops watching a source folder when an overlapping recursive source folder is removed from rescript.json
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- ocaml
- 领域
- devtools
调研方向
Start in rewatch/src/watcher.rs, especially compute_watch_paths and update_watches, and trace how overlapping paths are handled when the config changes. Check notify 5.2.0's Linux INotifyWatcher removal behavior described in the issue, then reproduce with the supplied Linux steps. Done means edits under src/retained are picked up after narrowing the source folders without restarting the watcher.
由索引模型根据 Issue 内容生成。
描述
Found by adversarial experiments on semantic analysts.
What is broken
rescript watch registers each source folder as its own watch, and overlapping folders are allowed. Consider sources [{"dir": "src", "subdirs": true}, "src/retained"], which become ["src/retained"] after an edit to rescript.json. On Linux, edits under src/retained are no longer picked up afterwards.
compute_watch_pathsgivessrc(recursive) andsrc/retained(non-recursive) separate entries.- On a config change,
update_watches(called at L599) does three things:- it keeps
src/retainedas unchanged; - it calls
unwatchon the stalesrc; - it registers only the paths that are not kept.
- it keeps
- On Linux,
RecommendedWatcheris notify'sINotifyWatcher. In notify 5.2.0 (the version locked inrewatch/Cargo.lock), unwatching a recursive path removes every watched path that starts with it (src/inotify.rs,remove_watch, lines 518–541 of the crate). That includes the separately registeredsrc/retained. update_watchesstill listssrc/retainedas registered, so it is never re-registered. The package root watch is non-recursive and does not seesrc/retained/*.res.
macOS (FSEvents) keeps the child watch, and there the scenario below works. The Linux result follows from the notify code above; I have not run it on Linux.
Reproduction (Linux)
mkdir -p proj/src/retained && cd proj
echo '{"name":"proj","version":"0.0.0","dependencies":{"rescript":"13.0.0-alpha.7"}}' > package.json
cat > rescript.json <<'EOF'
{"name":"proj","sources":[{"dir":"src","subdirs":true},"src/retained"],
"package-specs":{"module":"esmodule","in-source":true},"suffix":".mjs"}
EOF
echo 'let x = 1' > src/retained/Demo.res
npm install && (npx rescript watch &) && sleep 3
sed -i 's|"sources":.*"src/retained"\],|"sources":["src/retained"],|' rescript.json; sleep 3
echo 'let x = 2' > src/retained/Demo.res; sleep 3
grep 'let x' src/retained/Demo.mjs
Expected: let x = 2;. Per the code above, on Linux Demo.mjs keeps let x = 1; until the watcher restarts.
Introduced by
fb85e7bf8 (#8730). Before it, a full rebuild unregistered every path and registered the complete new list.
Impact
Linux users who narrow an overlapping source configuration while rescript watch runs get silently stale output for the retained folder. One fix is to treat a kept watch as stale when an ancestor recursive watch is removed. Another is to re-register every kept path below a removed recursive path.
- 主要语言
- ReScript
- 星标
- 7.5k
- 派生
- 483
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 120
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rescript-lang/rescript 的其他 Issue
-
难度 5/5 一周以上 新手友好度 25/100
rescript-lang/rescript#8833 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
rescript-lang/rescript#8806 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
rescript-lang/rescript#8798 ·
维护者通常 1 天内回复
-
难度 3/5 半天 新手友好度 58/100
rescript-lang/rescript#8757 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 40/100
rescript-lang/rescript#8753 ·
维护者通常 1 天内回复
查看 rescript-lang/rescript 的全部 Issue
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 62/100
andromarces/agent-loops#885 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
jbacalso24/mimry#290 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
interledger/rhyza#352 ·
维护者通常 1 天内回复
-
bug raised-by:desk
难度 2/5 1-3 小时 新手友好度 78/100
medici-finance/assay#3097 ·
维护者通常 1 天内回复
-
approved bug
难度 2/5 1-3 小时 新手友好度 70/100
checkstyle/checkstyle#21981 · 1 条评论 ·
维护者通常 1 天内回复