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
Watch mode should wait for file write. (T7411) #3698
Conversation
Current coverage is 88.32% (diff: 100%)@@ master #3698 diff @@
==========================================
Files 194 194
Lines 13611 13611
Methods 1427 1427
Messages 0 0
Branches 3142 3142
==========================================
Hits 12022 12022
Misses 1589 1589
Partials 0 0
|
There's an other PR related to this issue here: #3682. However, even with this change applied, I still noticed some fails, and eventually moved to a manual make/inotify-based watch system. |
@@ -71,7 +71,11 @@ module.exports = function (commander, filenames) { | |||
_.each(filenames, function (dirname) { | |||
let watcher = chokidar.watch(dirname, { | |||
persistent: true, | |||
ignoreInitial: true | |||
ignoreInitial: true, | |||
awaitWriteFinish: { |
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 like this was added in Chokidar 1.2 and our deps are currently ^1.0.0
, can we bump that up to the current version ^1.6.0
?
ignoreInitial: true, | ||
awaitWriteFinish: { | ||
stabilityThreshold: 50, | ||
pollInterval: 10, |
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.
This seems like a pretty fast interval, perhaps we should do more like 200
and 50
?
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.
200 is too close to perception threshold, IMO.
This is not continual poll, and is only active when change event occurs. Performance wise is probably not a big deal.
Works well for me, YMMV.
Anything blocking the merge of this patch? Seems the other PR was closed in favour of this one. The race condition is especially evident on machines with high latency storage (non-SSD). Noticing this about 50% of the time when saving files to HDD with vscode. /cc @teochengyong |
https://phabricator.babeljs.io/T7411#81534
The problem is that some editors (e.g. VScode) saves by truncating the file then writing. There's a race condition where
I am only seeing this problem happening with the combination of VSCode and Linux.
Fixing this problem would require adding
awaitWriteFinish
to chokidar's watch command.Not sure what default would work well for everybody. I am using 50ms stability threshold and 10ms polling intervals, which seems to behave well in my case.