Skip to content

Resolution cache defensive checks#19053

Merged
sheetalkamat merged 5 commits into
masterfrom
resolutionCacheDefensiveChecks
Oct 11, 2017
Merged

Resolution cache defensive checks#19053
sheetalkamat merged 5 commits into
masterfrom
resolutionCacheDefensiveChecks

Conversation

@sheetalkamat
Copy link
Copy Markdown
Member

@sheetalkamat sheetalkamat commented Oct 9, 2017

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

@sheetalkamat
Copy link
Copy Markdown
Member Author

@mhegazy or @Andy-MS can you please take a look.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just call startCachingPerDirectoryResolution from here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread src/compiler/watch.ts Outdated

if (hasChangedCompilerOptions) {
newLine = getNewLineCharacter(compilerOptions, system);
if (changesAffectModuleResolution(program && program.getCompilerOptions(), compilerOptions)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Would prefer program && changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions) since if !program, changesAffectModuleResolution has nothing it can do.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

getExternalFiles(): SortedReadonlyArray<string>;
getSourceFile(path: Path): SourceFile;
close(): void;
private detachScriptInfoIfNotRoot(uncheckedFilename);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have #8306 so we didn't need to include this..

@ghost
Copy link
Copy Markdown

ghost commented Oct 10, 2017

Fixes #19077 too?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

3 participants