Skip to content

Fix dotter watch redeploying in an endless loop - #234

Merged
SuperCuber merged 1 commit into
SuperCuber:masterfrom
johnw42:fix-watch-loop
Oct 25, 2026
Merged

SuperCuber merged 1 commit into
SuperCuber:masterfrom
johnw42:fix-watch-loop

Conversation

@johnw42

@johnw42 johnw42 commented Oct 25, 2026 •

Copy link
Copy Markdown

Problem

On Linux, dotter watch redeploys continuously even when nothing changes: about 18 deploys per second in my testing. Each deploy reads files in the repository and writes the cache, and the watcher picks up both:

  • Reads count as changes. Reading a file produces access events, which were treated like modifications.
  • The exclusions never applied. The cache directory, cache.toml, .git and DOTTER_SYMLINK_TEST were passed to GlobsetFilterer::new as !-prefixed lines in the filters argument. A negated filter only whitelists, and with no positive filters the filter set isn't consulted at all, so nothing was excluded.

Fix

  • Wrap the globset filterer to discard file access events.
  • Pass the exclusions as ignore patterns instead. Each excluded directory (the cache directory and .git) gets two patterns: .dotter/cache matches the directory itself, and .dotter/cache/** matches everything inside it. In .gitignore files, .dotter/cache/ alone would cover both, but in my testing the watcher's filter didn't apply that pattern to files inside the directory. Writing .dotter/cache/gitconfig still triggered a redeploy until I added the /** pattern.
  • Deploy once explicitly at startup. Until now this only happened as a side effect of the spurious events.

Testing

I ran dotter watch in a pseudo-terminal:

Scenario Before After
Idle, no changes ~18 [Dotter] Deploying... lines per second one line, at startup
Edit a symlinked file, a template, or global.toml continuous one redeploy per edit

cargo test, cargo clippy -- -D warnings and cargo fmt --check pass, and cargo check passes for the Windows and macOS targets.

🤖 Generated with Claude Code

Deploying reads files in the repository and writes to the cache, and both
retriggered the watcher, so `dotter watch` kept redeploying even when
nothing had changed.

- Discard file access events, which aren't modifications.
- Pass the cache, `.git` and symlink test paths as ignores rather than as
  negated filters. Negated filters alone never excluded anything. Ignore
  directories as `dir` and `dir/**`, since `dir/` doesn't exclude the files
  inside it.
- Deploy once on startup explicitly. This used to happen only as a side
  effect of the spurious events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SuperCuber
SuperCuber merged commit f418ab3 into SuperCuber:master Oct 25, 2026
9 checks passed
@SuperCuber

Copy link
Copy Markdown
Owner

I'm not running the latest version on windows myself so haven't noticed, thanks for the contribution!

SuperCuber pushed a commit that referenced this pull request Oct 26, 2026
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