Repository navigation
fix: stop two watch tests racing the events macOS replays - #1
Merged
Merged
Conversation
Both failed on every GitHub macos-14 run and passed here, which read as an
OS difference and was not one. macOS FSEvents delivers events for
filesystem activity that happened *before* the stream was created --
including the creation of the watched directory itself. Confirmed by
watching with a throwaway callback that printed whole `notify::Event`s: a
`Create(File)` and two `Modify`s for a write made 6ms before `watch()`
returned, plus a `Create(Folder)` for the watched directory. Both tests
assume the first event they see is one they caused.
`a_safety_timeout_with_nothing_changed_emits_nothing` writes tasks.jsonl
before `spawn_inner`. The replayed write comes back through the `Ok(())`
branch, which is not the branch under test and is not stat-gated at all --
so the test read a watcher event as the safety tick firing, which is
exactly backwards. It reproduces here 2 runs in 10 when run alone; the
full suite's timing is what hid it.
`a_change_reports_which_store_it_came_from` creates `a` and `b` before
`spawn_many`, and `a` reports its own creation before the deliberate write
to `b` lands -- the literal CI message, "reported the wrong store: .../a".
This one was hidden by a second bug: the test used a fixed
`temp_dir().join("dextui-watch-many")` that nothing ever cleaned up, so
after the first run the directories already existed and `create_dir_all`
was a no-op. It was passing 10/10 against a directory dated nine days
earlier. Deleting that directory reproduced the CI failure immediately,
which is what tied the two halves together.
The fix is `settle`, which waits for the channel to go quiet before
anything is asserted, so every event a test judges is one the test caused.
Condition-based rather than a fixed sleep, and capped, so a broken gate
fails rather than hanging. The test that used the shared path now gets a
`TempDir` per run like every other test in the module.
`SETTLE_QUIET` is over `DEBOUNCE`, and that is the load-bearing part. What
`settle` drains is `out`, and the `Ok(())` branch swallows the rest of a
burst for `DEBOUNCE` before sending -- so a raw event at 5ms becomes an
`out` send at 255ms, and a quiet window under 250ms returns mid-debounce
having seen nothing, handing the pending emission to the next assertion.
A first attempt at 200ms still failed 3 in 15 while the 300ms call site
passed 15/15, which is what pointed at the debounce.
Verified under the conditions that reproduced it -- each test alone, stale
directory removed each run -- 0/15 both, against 2/10 and 1/8 before. Full
suite 5x and clippy -D warnings clean.
Not changed: the app still does a `dex list` for each replayed event at
startup, one per watched store, on top of the initial load it already did.
That is wasted work rather than wrong output, and fixing it is a product
change, not a test fix.
Claude-Session: https://claude.ai/code/session_019vddQQKM4N7Mu72Cdqn9iy
actions/checkout@v4 targets Node 20, which the runners now force onto Node 24 with a deprecation warning on every job. dist's generated release.yml already pins v6, so this also stops the two workflows in the same repo disagreeing about the same action. Claude-Session: https://claude.ai/code/session_019vddQQKM4N7Mu72Cdqn9iy
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.
macOS FSEvents delivers events for filesystem activity that predates
watch(), including the creation of the watched directory itself. Both tests assumed the first event they saw was one they caused.Reproduced locally once the conditions were right — 2/10 and 1/8 — so this was never a CI-only quirk. The multi-store test was additionally masked by a fixed shared temp dir that nothing cleaned up, so it had been passing against directories dated nine days earlier; deleting that directory reproduced the CI failure immediately.
SETTLE_QUIETbeing overDEBOUNCEis the load-bearing part — a first attempt at 200ms still failed 3 in 15, because theOk(())branch swallows a burst for 250ms before it sends, so a shorter quiet window returns mid-debounce having seen nothing.Full reasoning in the commit message. Verified 0/15 both under the reproducing conditions, full suite 5x, clippy clean.
This PR exists mainly to get the macOS runner to confirm it, since that is where the failure was deterministic.
https://claude.ai/code/session_019vddQQKM4N7Mu72Cdqn9iy