-
Notifications
You must be signed in to change notification settings - Fork 637
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NodeWatcher - fix scan / add race, minimise recursive watch delay
Summary: This addresses some inconsistencies and bugs in the `NodeWatcher` (`fs.watch`-based fallback for non-Watchman, non-macOS), so we can improve test strictness ahead of other changes. ## Scan/'add' race As noted in the deleted test workarounds, there was previously a race when creating a subtree between 1. The scan of a subtree's contents in when processing the 'add' event for a root. 2. The 'add' event fired at or under the root for a new file or directory, if a watch has already been established. This could result in multiple add events emitted for a given file or directory. This diff makes some simple changes to ensure that an add event is only emitted for previously-unwatched directories or previously-unregistered files (`_watchdir` and `_register` return booleans). ## Watch initialisation delays A distinct but related issue occurred when a file was deleted from a new directory - the deletion may be missed if a watch hasn't yet been established on a new directory. This turned out to be at least in part because we perform the recursive watch by intercepting directory addition events *within* a debounce wrapper (ie, after an explicit delay). This diff moves the traversal to begin immediately on processing a directory addition. Reviewed By: jacdebug Differential Revision: D41713791 fbshipit-source-id: 714870799f3819a07e7cd96a6d8c87328aaa9ca6
- Loading branch information
1 parent
528c891
commit 51fb7e3
Showing
3 changed files
with
80 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters