Skip to content

Commit 4f80416

Browse files
kyliauKeen Yee Liau
authored andcommitted
fix: apply temporary fix to handle undefined language service
For some reasons, the project could end up in an inconsistent state where the language service is undefined. It could be that the project is closed (?!). While we investigate this issue, put in a temporary fix to force the project to reload. Also note that the return type of getLanguageService() is deceiving, because it could return undefined https://github.com/microsoft/TypeScript/blob/1c1cd9b08d8bf1c77abb57d195cc6d79b1093390/src/server/project.ts#L797
1 parent dd8a930 commit 4f80416

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

server/src/session.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,16 @@ export class Session {
511511
if (!project?.languageServiceEnabled) {
512512
return;
513513
}
514-
514+
// TODO(kyliau): For some reasons, the project could end up in an inconsistent
515+
// state where the language service is undefined. It could be that the project
516+
// is closed (?!). While we investigate this issue, put in a temporary fix
517+
// to force the project to reload.
518+
// Also note that the return type of getLanguageService() is deceiving,
519+
// because it could return undefined
520+
// https://github.com/microsoft/TypeScript/blob/1c1cd9b08d8bf1c77abb57d195cc6d79b1093390/src/server/project.ts#L797
521+
if (project.getLanguageService() === undefined) {
522+
project.markAsDirty();
523+
}
515524
return {
516525
languageService: project.getLanguageService(),
517526
scriptInfo,

0 commit comments

Comments
 (0)