Skip to content

Fix infinite rebuild loop with polling-based file watching#213

Open
Bizordec wants to merge 1 commit into
sphinx-doc:mainfrom
Bizordec:hotfix/rebuild-loop
Open

Fix infinite rebuild loop with polling-based file watching#213
Bizordec wants to merge 1 commit into
sphinx-doc:mainfrom
Bizordec:hotfix/rebuild-loop

Conversation

@Bizordec
Copy link
Copy Markdown

Problem

When watchfiles is using polling-based file watching, sphinx-autobuild enters an infinite rebuild loop. This happens because:

  1. During a build, file creation inside directories updates their metadata (mtime)
  2. watchfiles detects Change.modified events for these directories (metadata/mtime changes)
  3. sphinx-autobuild triggers a rebuild
  4. The rebuild modifies the directories again, creating a loop

Solution

Modify the watch_filter in RebuildServer.watch() to ignore Change.modified events for directories, while still accepting:

  • Change.modified only for files (actual content changes)
  • Change.created and Change.deleted for both files and directories (structure changes)

@Bizordec Bizordec force-pushed the hotfix/rebuild-loop branch from 0a83511 to f5eeb23 Compare May 22, 2026 12:43
@Bizordec Bizordec force-pushed the hotfix/rebuild-loop branch from f5eeb23 to e83cae6 Compare May 27, 2026 19:33
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