fix: do not emit spurious initial-scan change events for items created within FS_ACCURACY of startTime (#295)#299
Open
alexander-akait wants to merge 3 commits intomainfrom
Open
fix: do not emit spurious initial-scan change events for items created within FS_ACCURACY of startTime (#295)#299alexander-akait wants to merge 3 commits intomainfrom
alexander-akait wants to merge 3 commits intomainfrom
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 Sentry. 🚀 New features to boost your workflow:
|
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.
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