Skip to content

#1098 Report the true watch mode when the events directory is missing - #1101

Merged
williamthorsen merged 5 commits into
mainfrom
1098
Jul 28, 2026
Merged

#1098 Report the true watch mode when the events directory is missing#1101
williamthorsen merged 5 commits into
mainfrom
1098

Conversation

@williamthorsen

Copy link
Copy Markdown
Owner

What

Fixes an issue on Linux where Fleet's startup line claimed an active watch on its events directory even when that directory did not exist. The line now reports when Fleet is falling back to periodic rescans instead, naming the directory it could not watch and the reason.

Why

The startup line is the operator's only signal for whether low-latency updates are in effect, and the module's stated contract is that a fallback to periodic rescans is always announced. On Linux that promise was not being kept, and it was the watcher suite's failure on CI that surfaced it.

Details

🐛 Bug fixes

  • The watch mode is decided from a direct probe of the target directory rather than from whether starting the watch reported an error, so a missing directory produces the fallback line on every platform.
  • The fallback line names the directory and the underlying reason, replacing wording that attributed every failure to the watch API even when the directory was simply absent.

♻️ Refactoring

  • startWatcher resolves its watch through an injectable starter, matching the seams already used by createGitAdapter and createGithubAdapter. Production omits it and takes the default.

🧪 Tests

  • The debounce path and the mid-run watch-error downgrade are covered, both driven through an injected starter rather than real filesystem events.
  • A test asserts that a missing directory is detected before any watch is attempted, pinning the probe ahead of the watch.
  • One test exercises the default starter against an existing directory, so the production path stays covered.
  • Temp directories and watchers are scoped to the test that creates them.

Closes #1098

@github-actions

Copy link
Copy Markdown

Dependency audit

Production dependency audit passed.

@williamthorsen williamthorsen self-assigned this Jul 28, 2026
@williamthorsen
williamthorsen marked this pull request as ready for review July 28, 2026 18:09
Fleet's startup line names the watch mode actually in effect on every platform. On Linux, a missing events directory left it announcing an active recursive watch that had never started, and no later message corrected it.

The degraded-mode line names the directory that could not be watched and the underlying reason.
The watcher's announcement and degradation behavior is exercisable without an OS-level watch. Tests supply their own watch starter, and the module falls back to Node's recursive `fs.watch` when none is given.

Coverage now includes a watch that fails to start, and pins that a missing directory is detected before any watch is attempted.
The watcher suite covers a burst of watch events collapsing into a single dirty signal, and an error from the watch downgrading to rescan-only and releasing the handle.

Only the test asserting the default watch mode starts a real OS-level watch; the rest drive the module through an injected starter.
The watcher suite's temp directory and running watchers are created and released per test, by helpers that register their own teardown.

Module-level mutable state, `beforeEach`, and `afterEach` leave the file, and with them the three lint warnings it carried.
The burst test waits for the dirty signal itself rather than for a fixed interval long enough to contain it, so a garbage-collection pause or a loaded runner cannot fail it with zero calls.
@williamthorsen
williamthorsen merged commit 07ed996 into main Jul 28, 2026
3 checks passed
@williamthorsen
williamthorsen deleted the 1098 branch July 28, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The fleet watcher announces an active watch it never started on Linux

1 participant