Skip to content

fix: prevent infinite rebuild loops with custom output folders#492

Merged
azu merged 5 commits intomasterfrom
claude/investigate-issue-491-6a8ow
Jan 25, 2026
Merged

fix: prevent infinite rebuild loops with custom output folders#492
azu merged 5 commits intomasterfrom
claude/investigate-issue-491-6a8ow

Conversation

@azu
Copy link
Copy Markdown
Member

@azu azu commented Jan 25, 2026

Summary

  • Fix infinite rebuild loop when using honkit serve with custom output folder
  • Add tests for watch functionality

Problem

When using honkit serve with a custom output folder (not _book), files copied to the output folder were being detected by the watcher, causing a rebuild, which would copy files again, triggering another rebuild in an infinite loop.

Solutions

The fix passes the output folder to the watch function, which adds it to the ignored patterns list. This ensures that file changes in the output folder don't trigger unnecessary rebuilds.

Fixes #491

When using `honkit serve` with a custom output folder (not `_book`),
files copied to the output folder were being detected by the watcher,
causing a rebuild, which would copy files again, triggering another
rebuild in an infinite loop.

The fix passes the output folder to the watch function, which adds it
to the ignored patterns list. This ensures that file changes in the
output folder don't trigger unnecessary rebuilds.

Fixes #491
On Windows, path.relative() returns paths with backslashes, but glob
patterns require forward slashes. This ensures the output folder is
correctly ignored on Windows.
Use chokidar's ready event and Promise-based waitForChange helper
instead of arbitrary setTimeout delays. This makes tests faster and
more reliable.
- Change watch() to accept a single options object instead of positional args
- Rename 'dir' to 'watchDir' for clarity
- Fix test flakiness by adding stabilization delay after ready event
- Convert Windows backslashes to forward slashes in glob patterns
- Add normalizePath helper to handle path separator differences
- Increase timeouts for Windows file system operations
- Remove non-null assertions for type safety
@azu azu added the Type: Bug Bug or Bug fixes label Jan 25, 2026
@azu azu merged commit 4cc4615 into master Jan 25, 2026
20 checks passed
@azu azu deleted the claude/investigate-issue-491-6a8ow branch January 25, 2026 12:37
@github-actions github-actions bot mentioned this pull request Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Bug or Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

*Infinite Rebuild Loop when a Markdown file exists but is not listed in SUMMARY.md.

2 participants