Skip to content

Fix watch mode ignoring a file saved right after a rebuild started - #9403

Merged
cknitt merged 1 commit into
masterfrom
watch-lost-edit
Nov 24, 2026
Merged

cknitt merged 1 commit into
masterfrom
watch-lost-edit

Conversation

@cknitt

@cknitt cknitt commented Nov 24, 2026

Copy link
Copy Markdown
Member

Watch mode could ignore a saved file until it changed again. This is what made the "watch-retained-graph" test flaky on macOS CI: B.res was saved right after C.res, and B.js was never recompiled.

After a build, the native watcher took one snapshot of the sources to find what changed, then a second one as the baseline for the next round. A file saved between the two was already in the baseline, but no build was told about it. The changes now come from the snapshot that becomes the baseline, which is what the polling watcher already does.

New test: tests/rewatch_ounit_tests/watcher_tests.ml injects the watcher's source discovery, which runs between the two snapshots, so it can edit a file exactly in that window. It checks that the next build reports the edit. It fails every time with the old snapshot order. Injecting discover works the same way as the existing native_create injection.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH

After a build, the native watcher took one snapshot of the sources to
find what changed and then a second as the baseline for the next round.
A file saved between the two was in the baseline but was never reported
to a build, so watch mode ignored it until the file changed again. That is
the flaky "watch-retained-graph" test on macOS: B.res, saved right after
C.res, never got recompiled. The changes now come from the snapshot that
becomes the baseline, as the polling watcher already does.

A unit test injects the watcher's source discovery, which runs between the
two snapshots, to edit a file exactly there, and checks that the next build
reports it. It fails with the old snapshot order.

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

cknitt commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 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-24T07:51:41.922391Z 074a99c 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.

@github-actions

Copy link
Copy Markdown

Changelog

🐛 Bug fix

  • Fix watch mode sometimes ignoring a file saved right after a rebuild started.

Semantic Diff

1 commit · Full page

Rebuild edits made between the watcher's two snapshots

074a99c · cknitt + Claude · Nov 24, 2026, 07:47 UTC

After a build, the native watcher took one snapshot of the sources to find what changed and then a second as the baseline for the next round. A file saved between the two was in the baseline but was never reported to a build, so watch mode ignored it until the file changed again. That is the flaky "watch-retained-graph" test on macOS: B.res, saved right after C.res, never got recompiled. The changes now come from the snapshot that becomes the baseline, as the polling watcher already does.

A unit test injects the watcher's source discovery, which runs between the two snapshots, to edit a file exactly there, and checks that the next build reports it. It fails with the old snapshot order.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 074a99cc91

ℹ️ 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".

@github-actions

Copy link
Copy Markdown

✅ Compiler benchmarks

Allocated words

In total: 637,411,500 → 637,411,236 (±0.00%).

Generated projects: 629,041,985 → 629,041,568 (±0.00%).

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

Instructions

In total: 9,221,420,412 → 9,221,420,412 (±0.00%).

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

Output size

In total: 25,987,723 → 25,987,723 (±0.00%).

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

Pull request 074a99c compared with base 45dba2c in this run.

@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 074a99c

@github-actions

Copy link
Copy Markdown

@cknitt
cknitt marked this pull request as ready for review November 24, 2026 14:15
@cknitt
cknitt merged commit aacaf72 into master Nov 24, 2026
23 checks passed
@cknitt
cknitt deleted the watch-lost-edit branch November 24, 2026 14:28
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