| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@MoLow what do you think about this one ? |
Sorry, something went wrong.
|
As to my understanding, the issue described in #51954 (comment) isn't caused by the lack of debounce, but from a race condition where change events are fired between killing the process and restarting it. |
Sorry, something went wrong.
|
There are two problems described (although admittedly not very clearly) in issue #51954:
The first one is tackled by your PR #51992 The second problem, which also causes too many un-necessary restarts, is due to the fact that the current behavior does not act as a "debounce" but actually acts more as a "delayed throttle". Here is the definition of Debounce and Throttle
The current behavior is a mix between these two modes: The File watcher will wait X ms before emitting the first event, and will then continue emitting events (if the same file keep being updated) every X ms. In practice, this means that if the same file gets updated every 100ms, the changed event will be fired every 200ms (1 out of 2 events will be dropped). So the watcher will try and restart the app every 200ms (except for events occurring during restart). The issue is even worse when multiple files are concerned. Indeed, consider the following scenario (e.g. during a build or git checkout):
As you can see in this example, steps 10 to 13 yield un-necessary restarts. How many un-necessary restarts will depend on the number of file updated, the frequence at which they are updated, and the time the app takes to gracefully exit. But it is safe to say that updating files faster than the expected debounce rate (200ms) causes more restarts than needed. I would expect that only files updated slower than every 200 ms trigger multiple updates, not when updates are fasters than 200 ms. This is probably the main reason why tests are "flacky". Part of the flackyness is due to the behavior of the watcher and not to IO / performance reasons. node/test/parallel/test-watch-mode-files_watcher.mjs Lines 69 to 70 in 73025c4 This PR fixes that by:
|
Sorry, something went wrong.
|
Grouping all updated in a single event is something that was also suggested by @atlowChemi here |
Sorry, something went wrong.
|
Wouldn't this be a simpler fix with the same effect? #51986 |
Sorry, something went wrong.
| this.#debounceTimer = null; | ||
| const owners = this.#debounceOwners; | ||
| this.emit('changed', { owners }); | ||
| this.#debounceOwners = new SafeSet(); |
There was a problem hiding this comment.
| this.#debounceOwners = new SafeSet(); | |
| this.#debounceOwners.clear(); |
Sorry, something went wrong.
There was a problem hiding this comment.
The reason I did that is to allow async processing of the owners by the listeners. I figured it would be more efficient to swap the Set rather than doing:
const owners = new Set(this.#debounceOwners);
this.emit('changed', { owners });
this.#debounceOwners.clear();What do you think ?
Sorry, something went wrong.
There was a problem hiding this comment.
If you think that async processing of the event is not something we should care about here, then I can just implement your change.
Sorry, something went wrong.
Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
|
Hello @MoLow, The changes you suggested in #51986 have several issues:
|
Sorry, something went wrong.
|
Hey guys, any feedback you'd like to share on this ? |
Sorry, something went wrong.
|
It might be worth noting that one of the reason why it may have appeared as a single issue before, is that when trying to provide a solution (eg. in main...matthieusieben:node:patch-2), I provided an implementation that fixed both underlying causes by wrapping the changed event using a single "debouncer". But there were indeed two issues (an there is still this one) as explained (here and detailed here) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Partially fixes #51954 by reducing the amount of changed events in watch mode.