-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
watch: add global debounce #51986
watch: add global debounce #51986
Conversation
771ed41
to
d274f34
Compare
Co-authored-by: Matthieu <[email protected]>
d274f34
to
57ac709
Compare
These changes change the behavior of the class and might breaks its uses (1). They also fails to address one of the issues linked to the restart in watch mode (2).
|
this is the goal. I am a bit confused do want debouncing or not?
Not sure why you want to avoid effecting current behavior? |
Because of other uses of this class, like here |
that is watch mode for |
@@ -74,16 +76,17 @@ class FilesWatcher extends EventEmitter { | |||
} | |||
|
|||
#onChange(trigger) { | |||
if (this.#debouncing.has(trigger)) { | |||
if (this.#debouncing.has(trigger) || this.#debouncing.has(kGlobalDebounce)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always set the 2 of these together, can't we simplify by only setting & checking for the kGlobalDebounce
? (and drop the .add(trigger)
as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Piggy backing on this comment to emphasis that indeed, with this implementation, the second part of the if
will always be true if any other file already triggered as #onChange
. This not only renders the use of the this.#debouncing
set unnecessary (a simple boolean would suffice), but it also means that the owners
argument of the event will no longer contain all the owners. Indeed, a change to file A would cause kGlobalDebounce
to be set so that any change to file B would get ignored by this if
condition.
right but that implementation depends on the |
Something like this might not break the current behaviour. main...matthieusieben:node:patch-4 (#51988) This would still cause too many restarts in case of |
Superseded by #51992 |
Fixes #51954