Skip to content

Commit 30c4996

Browse files
authored
fix(language-server): Only enable language service on open projects (#1461)
After `ngcc` finishes, only enable language service for projects that are open. This avoids an error that would otherwise be thrown by TypeScript. It's not entirely clear what causes the project to close immediately after opening, but it appears to be triggered by having files open from multiple projects. The files not actively being displayed in the editor have their projects closed, but this also only appears to happen after having the editor open for a long time. Fixes #1438 Fixes #1399 - Not entirely sure this fixes the issue there, but it may and we don't currently have any other indicators for what the issue there might be if the cause is different.
1 parent a751e61 commit 30c4996

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

server/src/session.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ export class Session {
330330

331331
private enableLanguageServiceForProject(project: ts.server.Project) {
332332
const {projectName} = project;
333+
if (project.isClosed()) {
334+
this.info(`Cannot enable language service for closed project ${projectName}.`);
335+
return;
336+
}
333337
if (!project.languageServiceEnabled) {
334338
project.enableLanguageService();
335339
// When the language service got disabled, the program was discarded via

0 commit comments

Comments
 (0)