Repository navigation
fix: learn fs accuracy from directory mtimes too - #350
Conversation
A scan that saw only directories kept FS_ACCURACY at its 2000ms default, so directories created up to 2s before startTime were reported as changed (#295). Use the directory's mtime, not its birthtime, since FAT keeps creation times finer than modification times. Claude-Session: https://claude.ai/code/session_01D9gUmpCrb3uVLv6uR8av82
🦋 Changeset detectedLatest commit: 67324a2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughDirectory modification times now refine filesystem timestamp accuracy during event handling, scans, and followed directory symlinks. A regression test checks that watching a recently created directory with a current Priority: ⬇️ Low Severity of issue fixed: Low Merge Risk: 🔵 Low · up to
|
Merging this PR will not alter performance
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #350 +/- ##
==========================================
+ Coverage 92.45% 92.47% +0.02%
==========================================
Files 8 8
Lines 1338 1342 +4
Branches 396 399 +3
==========================================
+ Hits 1237 1241 +4
Misses 95 95
Partials 6 6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
All 41 test jobs, lint and the benchmark pass. Codecov can't be re-run from here. Generated by Claude Code |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8ee67b4d-eea3-476e-acc7-4d3111686363
📒 Files selected for processing: 3
.changeset/directory-fs-accuracy.mdlib/DirectoryWatcher.jstest/Watchpack.test.js
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
Fixes #295.
FS_ACCURACYstarts at 2000ms and is lowered byensureFsAccuracyfrom the mtimes the watcher sees, but only for files. A scan that finds only directories keeps the 2000ms default, sosafeTime = birthtime + 2000lands afterstartTimefor any directory created in the 2s before it, and it is reported as changed.The fix feeds the directory's mtime to
ensureFsAccuracyat the three placessetDirectorygets its value from a stat (watch event, scan, symlink to a directory). It uses mtime, not birthtime: FAT keeps creation times at 10ms but modification times at 2s, so learning from birthtime could shrink the margin below what file mtimes have and miss real changes. The safety margin itself is unchanged, unlike #299.The issue's script (subdirectory only, Linux):
watch({ startTime: Date.now() })change subdirchange subdir(inside the ~10ms margin, as for files)change subdirchange subdirNo extra rebuilds or missed changes
FS_ACCURACYdrop earlier, which lowerssafeTimeand can only remove events. A scan that sees any file already reached the same value.startTimeis still reported, both beforewatch()and while watching, with and without polling.WatchTestCases(2487 passed) andWatchCacheUnaffectedTestCases(2439 passed, 4 skipped) pass with thislib/.Tests
test/Watchpack.test.jsloads a fresh module (jest.isolateModules) soFS_ACCURACYstarts at 2000ms. It creates real directories and expects nochange. It fails without the fix (dir/subreported) and passes with it, also withWATCHPACK_POLLING=200.npm run lintclean, all added lines covered.🤖 Generated with Claude Code
https://claude.ai/code/session_01D9gUmpCrb3uVLv6uR8av82
Generated by Claude Code
Summary by CodeRabbit