fix: use chokidar raw events as fallback for suppressed file changes#7025
Draft
graygilmore wants to merge 1 commit intomainfrom
Draft
fix: use chokidar raw events as fallback for suppressed file changes#7025graygilmore wants to merge 1 commit intomainfrom
graygilmore wants to merge 1 commit intomainfrom
Conversation
chokidar's _handleFile listener compares mtimeMs and suppresses change events when mtime hasn't changed. Build tools that preserve timestamps (e.g. via touch --reference) cause silent misses on Linux/Windows. chokidar emits a raw event unconditionally, even when the mtime check suppresses the change event. This adds a raw event listener as a fallback: when a raw event fires, we start a short 100ms timeout. If chokidar's normal change event fires within that window, we cancel the timeout (normal path handled it). If the timeout expires, we trigger the handler ourselves. The existing handleFileUpdate already computes MD5 checksums and only syncs when content actually changes, so even if both paths fire, the checksum comparison prevents redundant uploads. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Coverage report
Test suite run success3814 tests passing in 1474 suites. Report generated by 🧪jest coverage report action from 2a3fcea |
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
rawevent listener on chokidar as a transparent fallback to catch file changes that chokidar suppresses when mtime is unchanged (common with build tools on Linux/Windows)changefires within the window, the raw fallback is cancelled; if not, we trigger the handler ourselveschangealways cancels the raw timeoutProblem
chokidar's
_handleFilelistener (nodefs-handler.js:369) comparesmtimeMsand suppresseschangeevents when mtime hasn't changed. Build tools that preserve timestamps cause silent misses on Linux/Windows.How it works
rawevent unconditionally, even when the mtime check suppresses thechangeeventrawevent fireschangefires within that window → cancel the timeout (normal path)changesuppressed) → trigger the handler ourselveshandleFileUpdatecomputes MD5 checksums and only syncs when content changed, preventing redundant uploads even if both paths fireTest plan
🤖 Generated with Claude Code