Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

rewatch watch on Linux stops watching a source folder when an overlapping recursive source folder is removed from rescript.json

Đang mở
#8,825 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@cknitt đang làm issue này rồi.

Từ ngày 12/10/2026.

  • #8839 của @cknitt — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
ocaml
Lĩnh vực
devtools

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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_paths gives src (recursive) and src/retained (non-recursive) separate entries.
  • On a config change, update_watches (called at L599) does three things:
    • it keeps src/retained as unchanged;
    • it calls unwatch on the stale src;
    • it registers only the paths that are not kept.
  • On Linux, RecommendedWatcher is notify's INotifyWatcher. In notify 5.2.0 (the version locked in rewatch/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 registered src/retained.
  • update_watches still lists src/retained as registered, so it is never re-registered. The package root watch is non-recursive and does not see src/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.

Ngôn ngữ chính
ReScript
Star
7.5k
Fork
483
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
120

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rescript-lang/rescript

Tất cả issue của rescript-lang/rescript

Issue tương tự

Thêm issue về DevTools

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.