Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the same debounced restart for all watchers (#2818)
### Motivation I noticed another issue with our restart watchers: they don't share the same debounced function. This matters because currently if two separate watchers are triggered in sequence, then we restart twice. This is of course not what we want. We want to restart a single time within the debounce time, no matter how many watchers have been triggered. ### Implementation The core of the issue is that if we have multiple debounced functions, they each have their own timeout object with a different ID. That leads to this scenario: 1. Rebase watcher fires its debounced restart 2. After rebase is complete, the lockfile was modified so that watcher is fired too 3. Because the debounced restart function of the lockfile is not the same as the rebase watcher, it won't clear the timeout of the rebase invocation 4. This triggers two consecutive restarts for no reason The fix is to ensure that we only have one single debounced restart function that is used by all of the watchers. This guarantees that, no matter which watcher is fired, it will always clear the previous restart timeout and avoid doing it multiple times.
- Loading branch information