rewatch watch on Linux stops watching a source folder when an overlapping recursive source folder is removed from rescript.json
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #8839 by @cknitt — merged
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- ocaml
- Domain
- devtools
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- ReScript
- Stars
- 7.5k
- Forks
- 483
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 130
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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 rescript-lang/rescript
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
rescript-lang/rescript#8878 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
rescript-lang/rescript#8806 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
rescript-lang/rescript#8798 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 Half a day Newbie friendliness 58/100
rescript-lang/rescript#8757 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 40/100
rescript-lang/rescript#8753 ·
Maintainers usually reply within 1 day
All issues in rescript-lang/rescript
Similar issues
-
docs: the dev-setup table and AGENTS.md name the reviewed_by guard that CI's Changelog job runsOpenarea: tools documentation good first issue ready for a contributor
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
eyalgolan/statecraft-israel#873 · 1 comment ·
Maintainers usually reply within 1 day
-
git-workflow task-4
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 1/5 Under an hour Newbie friendliness 87/100
777genius/agent-notifications#490 ·
Maintainers usually reply within 1 day
-
web / desktop client: model tooltip shows "No reasoning" for models that expose reasoning variantsOpenpending close triaging
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
anomalyco/opencode#56317 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
elastic/docs-builder#4495 ·
Maintainers usually reply within 1 day