Skip to content

Watch directories through polling when recursive options is not supported on the system #20207

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

Closed
wants to merge 11 commits into from

Conversation

sheetalkamat
Copy link
Member

Issue: Currently if system doesn't support watching directories recursively, we aren't watching the sub folders of the watched directories. But we rely heavily on recursive directory watching, either for failed lookup locations of module resolutions, watching for node_modules/@types or to watch directories specified through tsconfig itself (eg when it doesn't have file list or uses recursive directory inclusion pattern) That means on systems that don't support directory watching, if the files are added/removed in the sub folders of the directory being watched, there is no indication of such and program would get out of sync.

Fix: Watch the directories and its sub folders through polling (like fs.watchFile) for the changes. Currently for any changes either in the directory that's watched recursively or its sub directories, the callback is invoked for the directory being watched recursively. It works especially because we don't end up spending time to find changes that might not be important to project/program.

We could poll the directories and subdirectories just once and keep refcount avoiding duplicate polling of children, but that can be done as next PR.

Fixes #19989, #20023

@sheetalkamat
Copy link
Member Author

This PR is not ready for review since I am going to create a branch/drop that has few options with polling/non polling/recursive watching for user feedback. (as per discussion in #19762)
Here are some of the issues and reasons why we need to get feedback:

  • The issue with polling is that it is expensive since it keeps using resources, but it will give correct result.
  • Non polling depends on file system events, and node options supported, tends to get inaccurate in many scenarios and depending on OS it might just be not useful at all. But it is not resource heavy
  • On many OS there is limit of number of watches that can be created using fs.watch
  • we use polling watch for sourceFiles, missing File paths referenced and config file (which helps in being accurate), we watch directories in non polling mode (except for missing directories) which include wild card directories specified by config file directory, resolutions directory if not in config file directory
  • There is polling interval to be specified when watching files in poll mode, but we never use that to prioritize the files being watched and could benefit we could watch frequently updating files (more often than rest and to keep this set dynamic)

@sheetalkamat
Copy link
Member Author

Closing this in favor of #21243

@sheetalkamat sheetalkamat deleted the recursiveDirWatching branch February 23, 2018 21:46
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant