question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

So 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:

  1. So at some point doInitialScan is processed in DirectoryWatcher.
  2. This, at least for files, runs setFileTime
  3. As the inital flag is set, this this.files[filePath] = [initial ? Math.min(now, mtime) : now, mtime]; mostly equals to this.files[filePath] = [mtime, mtime];, because the file mtime will be smaller the time now (in case I edited file before running watcher).
  4. Next at some point it gets to process.nextTick and var ts = data[0] === data[1] ? data[0] + FS_ACCURACY : data[0]; and if(ts >= startTime)watcher.emit("change", data[1]);
  5. As this data[0] === data[1] is true (check point 3), FS_ACCURACY is added. So ts is bigger than startTime (delivered from webpack compiler it’s self.startTime = Date.now();).
  6. So for aprox 10 seconds (FS_ACCURACY = 10000 milis) it’ss spamming compile events, until the date now reaches file mtime+10 secs.

This doesn’t feel right 😕

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
YurySolovyovcommented, Feb 8, 2018

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.

1reaction
alexander-akaitcommented, Feb 8, 2018
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found