Skip to content

Stop dropping_handle_stops_events flaking on macOS - #38

Merged
fohara merged 1 commit into
mainfrom
fix/flaky-watcher-drop-test
Aug 9, 2026
Merged

fohara merged 1 commit into
mainfrom
fix/flaky-watcher-drop-test

Conversation

@fohara

@fohara fohara commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

watcher::tests::dropping_handle_stops_events has failed on macos-latest on
two unrelated PRs within an hour, so it is blocking merges rather than being a
curiosity.

What was happening

The test asserts that no events arrive after the watcher handle is dropped, but
it was also catching events queued before the drop. macOS FSEvents reports
changes from shortly before the stream opened, so the initial write the
fixture makes before starting the watcher could still be sitting in the channel
when the assertion ran. The failure was always a single stray tasks.md:

no events expected after handle is dropped; got [".../tasks.md"]

The fix

Drain the channel before the drop, so the assertion covers only events caused
after it.

What the test is for is preserved: drop joins the debouncer thread, so the
channel must be inert when it returns, and that is still asserted against the
ten writes made after the drop. There is deliberately still no settling sleep
after the drop, since that would hide a regression back to detached shutdown.

Ran the test 20 times locally after the change with no failures.

The test asserts that no events arrive after the watcher handle is
dropped, but it was also catching events queued before the drop. macOS
FSEvents reports changes from shortly before the stream opened, so the
`initial` write the fixture makes before starting the watcher could still
be sitting in the channel, and the assertion failed with a single stray
`tasks.md`.

Draining the channel before the drop keeps what the test is actually for.
The point is that `drop` joins the debouncer thread so the channel is
inert when it returns, and that still gets asserted against the ten
writes made after the drop. There is deliberately still no settling sleep
after the drop, since that would hide a regression back to detached
shutdown.

Seen on two unrelated PRs on macos-latest within an hour, so this was
blocking merges rather than being a curiosity.
@fohara
fohara merged commit 1160055 into main Aug 9, 2026
21 checks passed
@fohara
fohara deleted the fix/flaky-watcher-drop-test branch August 9, 2026 14:57
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.

1 participant