fix: use chokidar for reliable cross-platform file watching#14
Merged
Conversation
Replace Node's fs.watch({recursive:true}) with chokidar in
createFileWatcher. fs.watch recursive mode is not reliably supported
across platforms (notably nested directories on some Linux kernels),
so changes in subdirectories could be silently missed.
chokidar emits add/change/unlink events directly, which map onto the
existing FileChangeCallback, so the public API (signature, returned
{stop} shape, extension filtering, debounce, and ignore patterns) is
unchanged and src/commands/watch.tsx needs no modification.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces Node's
fs.watch({recursive: true})with chokidar insrc/lib/watch.tsfor reliable cross-platform file watching.Why
fs.watch'srecursiveoption is not reliably supported across platforms. On some Linux kernels recursive watching of nested directories is unsupported or flaky, so file changes in subdirectories (e.g.src/components/Header.php) could be silently missed duringkiqr watch. chokidar handles recursive watching consistently across macOS, Linux, and Windows.What changed
createFileWatchernow useschokidar.watch, listening to its nativeadd/change/unlinkevents — which map directly onto the existingFileChangeCallback.{stop}shape, same options (extension filtering, debounce, ignore patterns).src/commands/watch.tsxneeds no changes.getRelativePathis untouched.ignoredpredicate (so it won't even descend intonode_modules,.git, etc.) while preserving the existing regex/string-arrayignoredoption.Tests
tests/lib/watch.test.tsupdated to run against real temp-dir filesystem events with chokidar timing, and a new test verifies detection of files created in nested subdirectories.npm run typecheck✅npm test✅ (71 tests, 14 files)npm run build✅🤖 Generated with Claude Code