Skip to content

resolutionCache getDirectoryToWatchFailedLookupLocation always sets recursive watcher for entire project #26002

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
mprobst opened this issue Jul 27, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@mprobst
Copy link
Contributor

mprobst commented Jul 27, 2018

getDirectoryToWatchFailedLookupLocation in resolutionCache.ts checks if a failed lookup location is in the project's root dir, and if so, watches the entire project root, recursively (intentionally, it has a comment // Always watch root directory recursively).

For projects containing potentially very many subdirectories (just large projects, but also projects with large node_modules subtrees), this will read thousands of directories and create corresponding thousands of watchers.

I wonder if we could do better, but I don't understand the thinking that went into this. Was the idea that just having a recursive watch on the root is more effective than watching lots of more precise locations?

I'd consider only adding a watch for the closest non-existing file from the lookup location, e.g. for a location /foo/bar/baz/index.ts not being found, with baz/ not existing, a watch on /foo/bar would be sufficient, and create fewer watches and file reads than watching every file in the project recursively.

@sheetalkamat
Copy link
Member

This is fixed in #25811 note that we would still watch sub directory since watching each loacation or watching directory of each location lakes too much time on big projects.

@mhegazy mhegazy added the Bug A bug in TypeScript label Jul 27, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jul 27, 2018
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants