Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#8,825 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@cknitt já está trabalhando nisso.

Desde 12/10/2026.

  • #8839 de @cknitt — aberto

Avaliação

Dificuldade
4/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
ocaml
Domínio
devtools

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
OCaml
Estrelas
7.5k
Forks
484
Merge médio
20h 27min
PRs com merge (30d)
120

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de rescript-lang/rescript

Todas as issues de rescript-lang/rescript

Issues semelhantes

Mais issues de DevTools

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.