Repository navigation
fix(daemon): a file written right after its new folder is seen on Linux - #604
Merged
Merged
Conversation
notify's inotify backend watches a new directory only after the handler of its event batch returned (notify 8.2, `inotify.rs`: handlers first, `add_watch` after). The watcher listed the new directory inside that handler, before the watch: a file written in between was in neither the listing nor any event, and its change made no candidate until the next edit. This is how `edits_become_candidates` failed now and then on Linux. A new directory is listed once more 200 ms after its event was handled, on one thread per watcher (`feed`), and what it finds is delivered as any change. The handling of events moved into `feed`, which the new test drives with real inotify. Closes #587 Bug-Class: race-on-start Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7schmiede
force-pushed
the
fix/587-watch-new-dir-race
branch
from
November 20, 2026 16:19
006a359 to
5cd314c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
On Linux a file written right after its new folder was missed now and then (
edits_become_candidatesfailed twice on 2026-11-18): no build, no candidate, until the next edit.inotify.rs:handle_eventat the end of the read loop,add_watchafter it). The watcher listed the new directory inside that handler, so before the watch: a file written in between was in neither the listing nor an eventrace-on-startfeed); what it finds is delivered like any change (a candidate or restart waits for its debounce anyway)a_file_written_right_after_its_new_folder_is_reported, real inotify throughfeed(the production path), a handler that takes 30 ms as the daemon's does: red on Linux with all five files missed (never reported: ["src0/v2.txt", …]), green with the fix, three repeats green, all 21 watcher tests green, clippy clean (run in arust:1-bookwormcontainer; the test is Linux-only)remote.rs,watch_worktree) only sets a flag; its sync lists the whole worktree up to 2 s later and in full every 30 s, after the watch is in place: left as it is. macOS (FSEvents) and Windows report a new directory's files themselvesfeedthe daemon uses, with the real OS watchCloses #587
🤖 Generated with Claude Code