-
-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix in calculation of modified time of files in watch mode #3198
Bugfix in calculation of modified time of files in watch mode #3198
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.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, lets wait for CI to be green.
/cc @webpack/cli-team need one more review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Thanks |
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.js
is 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
changeTime
value comes through theWatchMethod
value ofWatchFileSystem
type, ultimately tracing back to thewatchpack
package. Watchpack usesfs.lstat
to retrieve afs.Stat
object 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 amtimeMs
on 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