Repository navigation
fix: do not emit spurious initial-scan change events for items created within FS_ACCURACY of startTime (#295) - #299
alexander-akait wants to merge 3 commits into
Conversation
…d within FS_ACCURACY of startTime (#295) DirectoryWatcher previously compared an entry's `safeTime` (`Math.min(now, mtime) + FS_ACCURACY`) against the watcher's `startTime`. Because `safeTime` is intentionally inflated by `FS_ACCURACY` to give callers an upper bound on possible modification time, every file or directory whose actual mtime/birthtime was up to `FS_ACCURACY` (initially 2000ms, typically 10ms after a single mtime is observed) before `startTime` was being flagged as changed during the initial scan. The `startTime` filter now compares against the raw mtime/birthtime instead, so only entries actually modified at or after `startTime` trigger a change event during initial scan. The change event payload still carries `safeTime` as before, and an additional optional `rawTimestamp` argument is forwarded so nested directory watchers can re-filter against the same raw timestamp. The "outdated on attach" path in `watch()` continues to use `safeTime` because its semantics are different: it represents "the last time the file was known to be in a stable state", which is the right value to compare against a newly attached watcher's startTime. https://claude.ai/code/session_01CfqWhrftEvFkN5GiG82P67
…r change The fix changes which initial-scan `change` events fire for files created within `FS_ACCURACY` of `startTime`. Downstream consumers (including webpack) may have been observing those events to invalidate caches; mark the changeset accordingly. https://claude.ai/code/session_01CfqWhrftEvFkN5GiG82P67
The fix aligns behavior with the documented "watching can be started in the past" semantics. The previously-spurious initial-scan events were undocumented and surprising (as the issue itself notes), so the realistic risk of breaking a downstream consumer that relied on them is low — patch is the right level. https://claude.ai/code/session_01CfqWhrftEvFkN5GiG82P67
|
🦋 Changeset detectedLatest commit: 7d301fc 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #299 +/- ##
==========================================
+ Coverage 95.82% 95.88% +0.06%
==========================================
Files 7 7
Lines 1173 1192 +19
Branches 342 355 +13
==========================================
+ Hits 1124 1143 +19
Misses 44 44
Partials 5 5
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:
|
|
Closing in favor of #350. This PR compares the raw mtime/birthtime with #350 fixes #295 without removing the margin: it learns the real accuracy from directory mtimes too, so directories stop being reported as changed on normal filesystems. Generated by Claude Code |
DirectoryWatcher previously compared an entry's
safeTime(
Math.min(now, mtime) + FS_ACCURACY) against the watcher'sstartTime. BecausesafeTimeis intentionally inflated byFS_ACCURACYto give callers an upper bound on possible modificationtime, every file or directory whose actual mtime/birthtime was up to
FS_ACCURACY(initially 2000ms, typically 10ms after a single mtimeis observed) before
startTimewas being flagged as changed duringthe initial scan.
The
startTimefilter now compares against the raw mtime/birthtimeinstead, so only entries actually modified at or after
startTimetrigger a change event during initial scan. The change event payload
still carries
safeTimeas before, and an additional optionalrawTimestampargument is forwarded so nested directory watcherscan re-filter against the same raw timestamp.
The "outdated on attach" path in
watch()continues to usesafeTimebecause its semantics are different: it represents "thelast time the file was known to be in a stable state", which is the
right value to compare against a newly attached watcher's startTime.
https://claude.ai/code/session_01CfqWhrftEvFkN5GiG82P67