Bugfix in calculation of modified time of files in watch mode#3198
Merged
rishabh3112 merged 1 commit intowebpack:masterfrom Apr 11, 2022
Merged
Bugfix in calculation of modified time of files in watch mode#3198rishabh3112 merged 1 commit intowebpack:masterfrom
rishabh3112 merged 1 commit intowebpack:masterfrom
Conversation
We need to pass the timestamp in milliseconds to the date constructor, this code was assuming that changeTime was in seconds and needed to be multiplied by 1000 to get milliseconds but it is already in milliseconds. This led to the constructed date being incorrect.
|
|
Codecov Report
@@ Coverage Diff @@
## master #3198 +/- ##
=======================================
Coverage 90.98% 90.98%
=======================================
Files 23 23
Lines 1731 1731
Branches 519 519
=======================================
Hits 1575 1575
Misses 156 156
Continue to review full report at Codecov.
|
rishabh3112
approved these changes
Apr 11, 2022
Member
rishabh3112
left a comment
There was a problem hiding this comment.
Looks good, lets wait for CI to be green.
Member
|
/cc @webpack/cli-team need one more review |
Member
|
Thanks |
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.
What kind of change does this PR introduce?
Bugfix
Did you add tests for your changes?
No, seemed too niche for a test case but happy to add one with a bit of instruction (namely whether
test/plugin/plugin.test.jsis the correct spot)If relevant, did you update the documentation?
Not relevant, updates a verbose log
Summary
Fixes #3197
We need to pass the timestamp in milliseconds to the date constructor, this code was assuming that changeTime was in seconds and needed to be multiplied by 1000 to get milliseconds but it is already in milliseconds.
This led to the constructed date being incorrect.
Does this PR introduce a breaking change?
No
Other information
It appears that the
changeTimevalue comes through theWatchMethodvalue ofWatchFileSystemtype, ultimately tracing back to thewatchpackpackage. Watchpack usesfs.lstatto retrieve afs.Statobject of the file and retuns the mtime by casting it to a number using the+operand. This might cause some platform-dependant behaviour, such as if+new Date()returns different levels of precision between Mac/Windows/Linux/etc. There's amtimeMson the Stat object that might be more appropriate in this case to ensure a certain level of precision is returned.Ref: https://nodejs.org/api/fs.html#stat-time-values