Skip to content

Skip watch rebuilds for files whose content didn't change - #9305

Merged
cknitt merged 1 commit into
masterfrom
watch-skip-unchanged
Nov 14, 2026
Merged

cknitt merged 1 commit into
masterfrom
watch-skip-unchanged

Conversation

@cknitt

@cknitt cknitt commented Nov 14, 2026

Copy link
Copy Markdown
Member

The macOS leg of CI fails "Run rewatch snapshot tests" now and then (11 first attempts since 2026-11-08). Each time it's the quiet-watch case in rewatch-ocaml/tests/check_command_validation.sh: the same parse error is printed twice.

There are two causes:

  • The watcher rebuilds when nothing changed. macOS can report one write twice, the second time after the 50 ms drain window. native_loop in watcher.ml re-read the file and rebuilt even when it matched the snapshot, so the error was printed again. update_entries now says whether anything differs (Unchanged, Updated, Not_in_snapshot), and the loop skips the build when nothing does. The polling and reconcile paths already did this. A file that can't be read still counts as changed, so its build still runs and reports the problem.
  • The test's filter for repeated reports didn't work. It split the output at Syntax error!. Since Remove the Rust build system #9238 each report starts with a blank line, so the copies differed by one newline and were never merged. The split now goes before that blank line, and it also works with CRLF output.

New unit tests in watcher_tests.ml: re-reading an unchanged file returns Unchanged, before and after an update.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kbf3gG8vKzkJGrU7AZ1CXQ

Why:
    macOS can report one write twice, the second time after the 50 ms
    drain window. The native watch loop re-read the file and rebuilt even
    when nothing differed from its snapshot, so a parse error was printed
    twice. This made the quiet-watch case of check_command_validation.sh
    fail on macOS in about 4% of CI runs. The test's filter for repeated
    reports had stopped working with the new report format in #9238.

Diagnostic modified (repeated content event in watch mode):
Example:
    let value =
Before (diagnostic): rescript watch --quiet after one save on macOS

      Syntax error!
      <ROOT>/src/A.res:1:12-2:0
    …
      This let-binding misses an expression

      Syntax error!
      <ROOT>/src/A.res:1:12-2:0
    …
      This let-binding misses an expression
After (diagnostic):

      Syntax error!
      <ROOT>/src/A.res:1:12-2:0
    …
      This let-binding misses an expression

Review: Does a read error still rebuild? Yes. update_entries counts a
kept entry as a change, as before, so the build reports the problem.

Review: Does touching a file still rebuild? Yes. The entry holds the
modification time, as in the polling loop, so only an event for a file
that is exactly as the snapshot recorded it is skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gG8vKzkJGrU7AZ1CXQ
Signed-off-by: Christoph Knittel <ck@cca.io>
@github-actions

Copy link
Copy Markdown

Changelog

🐛 Bug fix

  • Watch mode no longer rebuilds, and prints the same errors again, when one file change is reported twice.

Semantic Diff

1 commit · Full page

Skip watch rebuilds for files whose content didn't change

b5f76a2 · cknitt + Claude · Nov 14, 2026, 10:14 UTC

Why

macOS can report one write twice, the second time after the 50 ms drain window. The native watch loop re-read the file and rebuilt even when nothing differed from its snapshot, so a parse error was printed twice. This made the quiet-watch case of check_command_validation.sh fail on macOS in about 4% of CI runs. The test's filter for repeated reports had stopped working with the new report format in #9238.

Diagnostic modified (repeated content event in watch mode)

let value =

diagnostic · Before

rescript watch --quiet after one save on macOS
  Syntax error!
  <ROOT>/src/A.res:1:12-2:0
…
  This let-binding misses an expression

  Syntax error!
  <ROOT>/src/A.res:1:12-2:0
…
  This let-binding misses an expression

diagnostic · After

  Syntax error!
  <ROOT>/src/A.res:1:12-2:0
…
  This let-binding misses an expression

Review

  • Does a read error still rebuild? Yes. update_entries counts a kept entry as a change, as before, so the build reports the problem.
  • Does touching a file still rebuild? Yes. The entry holds the modification time, as in the polling loop, so only an event for a file that is exactly as the snapshot recorded it is skipped.

@github-actions

Copy link
Copy Markdown

✅ Compiler benchmarks

Allocated words

In total: 640,949,305 → 640,950,354 (±0.00%).

Generated projects: 920,892,047 → 920,892,290 (±0.00%).

None of the 265 benchmarks changed by 0.1% or more.

Instructions

In total: 9,209,713,865 → 9,209,713,865 (±0.00%).

None of the 33 benchmarks changed by 0.1% or more.

Output size

In total: 25,843,406 → 25,843,406 (±0.00%).

None of the 13 benchmarks changed by 0.1% or more.

Pull request b5f76a2 compared with base 1efa212 in this run.

@pkg-pr-new

pkg-pr-new Bot commented Nov 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@9305

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@9305

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@9305

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@9305

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@9305

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@9305

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@9305

commit: b5f76a2

@github-actions

Copy link
Copy Markdown

@cknitt

cknitt commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T19:46:20.822375Z b5f76a2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cknitt
cknitt marked this pull request as ready for review November 14, 2026 19:45
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: b5f76a2cf4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cknitt
cknitt merged commit a531dc3 into master Nov 14, 2026
22 checks passed
@cknitt
cknitt deleted the watch-skip-unchanged branch November 14, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants