-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[5.6-beta] #57196 Searching ancestor and its references for default projects regresses TSServer performance for orphaned files #59443
Comments
Currently disableSolutionSearching controls solution searching for file open as well as for find all references .. we are looking for feedback on why we would need two flags We have to load projects because not all files in the program are part of given by projects , some of the d ts files could be opened and are part of the project so there is no guarantee if we found project till we have loaded it .. |
What about something like
I don't think I really understand why a project needs to be loaded to determine if it contains a source file. Is that just not just a function of matching the |
There are plans to reimplement it, but in a way that doesn't hurt performance (or maybe more generally improves performance / reduces unnecessary loads). |
Thanks, in that case I'll leave it up to y'all's judgement whether this should be closed |
#59688 should have fixed this. |
π Search Terms
Search ancestor and its references for default projects orphan solution
π Version & Regression Information
β― Playground Link
No response
π» Code
No response
π Actual behavior
Context: We have a monorepo with thousands of projects. Roughly, the layout of the codebase follows this structure:
tsconfig.json
- "solution style" tsconfig that references all othertsconfig.json
filesfolderA
*.tsx
filestsconfig.json
- "solution style" tsconfig that points to the siblingtsconfig.non_test.json
andtsconfig.test.json
filestsconfig.non_test.json
- Includes all non-test source files in the current directory, excluding ones that are in projects in sub-directories, such as insubSubFolderA
.tsconfig.test.json
- Includes all test source files in the current directory, excluding ones that are in projects in sub-directories, such as insubSubFolderA
.subFolderA
*.tsx
filessubSubFolderA
*.tsx
filestsconfig.json
tsconfig.non_test.json
tsconfig.test.json
folderB
tsconfig.json
tsconfig.non_test.json
tsconfig.test.json
We used to have to maintain these tsconfig files by hand, but now they are all generated using our tooling built around Bazel which can do intelligent things like infer what project references a project needs by looking at the imports in its source files.
Anyway, the reason I described all this is to make it easier to see how for us it's a common workflow when creating a new project to create new files and then generate the tsconfig after the fact. The period before the tsconfig file is generated, all of the new files are treated as orphans. When any of these files are opened in VSCode, TSServer will search all the way up the project tree, looking at all the solution tsconfigs along the way, and loading all of the projects referenced. This eventually reaches the
tsconfig.json
in the root, which leads to all projects being loaded into the project graph. At this point TSServer will eventually creep up past the 48 GB memory limit we've generously given it until it crashes.I spent many hours last week debugging what was happening (literally attaching a debugger to tsserver.js and stepping through the code). It was not until seeing the 5.6 beta announcement did I realize that this was a recent change (we have been using nightly versions to access isolatedDeclarations and noCheck). Up until recently, our root
tsconfig.json
actually had a different name, so it wasn't part of the ancestor search. We named it back totsconfig.json
to reduce confusion for our developers, so I had only ascribed our recent problem to that change.π Expected behavior
Something that wasn't clear to me during my debugging was why TSServer needed to actually load a project into the graph in order to determine whether it contained a given source file. Maybe there's a good reason for this, but perhaps that's an opportunity for optimization so that a project is only gets loaded if an open file belongs to it or a project that transitively references it.
It would be great to have some way to opt back into the pre-#57196 behavior. This seems like it would be straight-forward by adding a tsconfig option to indicate that if an owner exists for a source file, it won't be in an ancestor. Example:
The actual solution I eventually went with was to patch TSServer so that when it recursively traverses project references, it skips over ones that could not possibly contain the triggering source file, simply by looking to see if the path of the tsconfig was a prefix of the other source file path (our
rootDir
is always the default). I produced the patch for that below (I don't have a branch to share because yes, I modified the already bundled JS file by hand, instead of working from the original source and building it). It could also be valuable to expose a tsconfig option to simulate this behavior. Example:Additional information about the issue
Our workaround patch
The text was updated successfully, but these errors were encountered: