Watch recursion
See original GitHub issueSo recently I got problems in webpack, where the watcher is spamming “compile” events for files that are updated before watching starts. The rabbit hole was deep, but led me to watchpack.
So:
- So at some point
doInitialScanis processed inDirectoryWatcher. - This, at least for files, runs
setFileTime - As the
initalflag is set, thisthis.files[filePath] = [initial ? Math.min(now, mtime) : now, mtime];mostly equals tothis.files[filePath] = [mtime, mtime];, because the file mtime will be smaller the time now (in case I edited file before running watcher). - Next at some point it gets to
process.nextTickandvar ts = data[0] === data[1] ? data[0] + FS_ACCURACY : data[0];andif(ts >= startTime)watcher.emit("change", data[1]); - As this
data[0] === data[1]istrue(check point 3),FS_ACCURACYis added. Sotsis bigger thanstartTime(delivered from webpack compiler it’sself.startTime = Date.now();). - So for aprox 10 seconds (FS_ACCURACY = 10000 milis) it’ss spamming compile events, until the date
nowreaches file mtime+10 secs.
This doesn’t feel right 😕
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Recursion - Sci-fi Horror Short - YouTube
0:00. 10:35 · New! Watch ads now so you can enjoy fewer interruptions. Got it.
Read more >Using Trace To Watch Recursion - Colin Allen
Lisp provides a nice way to watch the recursive process using trace. Enter the following: > (trace power) POWER > (power 3 4)...
Read more >Using Trace To Watch Recursion
LISP provides a nice way to watch the recursive process using trace. Enter the following: >(trace power) POWER >(power 3 4) 1> (POWER...
Read more >Watch The Recursion Theorem | Prime Video - Amazon.com
Meet Dan Everett. Imprisoned in an unfamiliar reality with strange new rules, Dan struggles to find reason as he is forced to question...
Read more >mafintosh/recursive-watch - GitHub
Minimal recursive file watcher. Uses the native recursive fs.watch option on macOS/Windows and basic recursive dir watching on Linux. npm install recursive- ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Adjusting concurrency seems like a crutch, race condition like that should never happen by design.
If that means things will go slower, it is fine, cause spamming like that confusing and slowing developers anyway.
Please, dear core team, do not trade speed for correctness and robustness.
@trsh duplicate https://github.com/webpack/watchpack/issues/53?