Resolution cache defensive checks#19053
Merged
Merged
Conversation
…d because of exception Fixes #18975
Member
Author
ghost
reviewed
Oct 10, 2017
| resolvedTypeReferenceDirectives.clear(); | ||
| allFilesHaveInvalidatedResolution = false; | ||
| Debug.assert(perDirectoryResolvedModuleNames.size === 0 && perDirectoryResolvedTypeReferenceDirectives.size === 0); | ||
| // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update |
There was a problem hiding this comment.
Could just call startCachingPerDirectoryResolution from here?
Contributor
There was a problem hiding this comment.
Should an exception during program update be recoverable? Might it be more useful to crash tsserver if we throw during program update and don't catch until the event loop?
|
|
||
| if (hasChangedCompilerOptions) { | ||
| newLine = getNewLineCharacter(compilerOptions, system); | ||
| if (changesAffectModuleResolution(program && program.getCompilerOptions(), compilerOptions)) { |
There was a problem hiding this comment.
Nit: Would prefer program && changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions) since if !program, changesAffectModuleResolution has nothing it can do.
| getExternalFiles(): SortedReadonlyArray<string>; | ||
| getSourceFile(path: Path): SourceFile; | ||
| close(): void; | ||
| private detachScriptInfoIfNotRoot(uncheckedFilename); |
There was a problem hiding this comment.
Would be nice to have #8306 so we didn't need to include this..
|
Fixes #19077 too? |
mhegazy
approved these changes
Oct 10, 2017
This was referenced Oct 11, 2017
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Handle the case when finishCachingPerDirectoryResolution is not called because of exception
Fixes #18975
Assert if the script info that is attached to closed project is present. This also releases external project files that get attached to the project when project is closed
Handle project close to release all the script infos held by the project. Above assert revealed that if the project update was pending and project is closed, the files added as root but not yet in program (because the project's update graph was pending/delayed) wont be released and hence those script infos holding onto the closed project.
Fixes #19003 and #18928