Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#8,825 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@cknitt ci sta già lavorando.

Dal 12/10/2026.

  • #8839 di @cknitt — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
ocaml
Ambito
devtools

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
OCaml
Stelle
7.5k
Fork
484
Merge medio
18h 19m
PR unite (30g)
116

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rescript-lang/rescript

Tutte le issue di rescript-lang/rescript

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.