I've noticed this strange behaviour where watcher loops for 10 seconds due to this code:
if(data) {
var ts = data[0] === data[1] ? data[0] + FS_ACCURENCY : data[0];
if(ts > startTime)
watcher.emit("change", data[1] + FS_ACCURENCY);
}
|
if(data) { |
|
var ts = data[0] === data[1] ? data[0] + FS_ACCURENCY : data[0]; |
|
if(ts > startTime) |
|
watcher.emit("change", data[1] + FS_ACCURENCY); |
What I'm doing in my script is basically creating a file in a temporary directory /temp/entry.js, creating a webpack compiler and run compiler.watch(). Now for 10 seconds (which is the default value of FS_ACCURENCY) this is what's happening:
- compilation succeeds
- Watching.prototype._done gets called
- recalling Watching.prototype.watch
- which immediately triggers a change event for the
/temp/entry.js file, because it's < 10 seconds old
- back to step 1
Any pointers on how to fix this would be helpful. For example, this could be fixed by modifying the above code to this, but I'd need to stare at this for longer to understand what this block of code is conceptually responsible for.
if(ts > startTime + FS_ACCURENCY) {
I've noticed this strange behaviour where watcher loops for 10 seconds due to this code:
watchpack/lib/DirectoryWatcher.js
Lines 202 to 205 in 7efdd93
What I'm doing in my script is basically creating a file in a temporary directory
/temp/entry.js, creating a webpack compiler and runcompiler.watch(). Now for 10 seconds (which is the default value of FS_ACCURENCY) this is what's happening:/temp/entry.jsfile, because it's < 10 seconds oldAny pointers on how to fix this would be helpful. For example, this could be fixed by modifying the above code to this, but I'd need to stare at this for longer to understand what this block of code is conceptually responsible for.