You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--watch not running with last file content when file changes multiple times #48909
constructor({ throttle =500, mode ='filter', signal }=kEmptyObject){
that number was chosen arbitrarily just as a heuristic on how often ides/users save files, and obviously, watch mode is designed to work with ides and not scripts like the above.
that being said - if you believe we should decrease this value a PR is welcomed
I believe people expect file watchers to act in a eventually consistent way where if files stop changing it eventually runs and produces an output based on the final state of the filesystem.
I tried to not prescribe a solution in my original ticket as I would personally be fine with any debounce/throttle logic that achieves this.
Some alternatives that would fulfill this would be:
Only run at the end of the timeout.
Same as 1 but extend the timeout every time a change is detected.
Run immediately and if new changes are detected run again at the end of the timeout.
Same as 3 but extend the timeout every time a change is detected.
I encountered this issue when i watched a file produced by a build tool. The build tool touched the file twice. First doing basically nothing to it and then updating it. It was very surprising to me that the the code that ran last didn't match the code i could see on disk.
Activity
MoLow commentedon Jul 25, 2023
watch mode is throttled for a change once in every 500 ms,
see
node/lib/internal/watch_mode/files_watcher.js
Line 34 in 71165e1
that number was chosen arbitrarily just as a heuristic on how often ides/users save files, and obviously, watch mode is designed to work with ides and not scripts like the above.
that being said - if you believe we should decrease this value a PR is welcomed
GabbeV commentedon Jul 25, 2023
I believe people expect file watchers to act in a eventually consistent way where if files stop changing it eventually runs and produces an output based on the final state of the filesystem.
I tried to not prescribe a solution in my original ticket as I would personally be fine with any debounce/throttle logic that achieves this.
Some alternatives that would fulfill this would be:
I encountered this issue when i watched a file produced by a build tool. The build tool touched the file twice. First doing basically nothing to it and then updating it. It was very surprising to me that the the code that ran last didn't match the code i could see on disk.
MoLow commentedon Jul 25, 2023
reopening - maybe we should change from throttle to debounce