Skip to content

tsserver plugin crashes due to undefined typeAcquistion #20321

Closed

Description

@kyliau

While investigating a crash in the Angular Language Service plugin during startup,
I found out that the root cause is due to an undefined typeAcquisition of the project.

When a new Configured Project is created, the Angular plugin needs to find all the external
files, but it is unable to do so before the typeAcquisition is set.

The stack trace is as follows:

Info 17   [18:17:59.459] A plugin threw an exception in getExternalFiles: TypeError: Cannot read property 'enable' of undefined
Info 18   [18:17:59.464] TypeError: Cannot read property 'enable' of undefined
    at ConfiguredProject.Project.getGlobalCache (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:82706:49)
    at resolveModuleName (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:82006:46)
    at resolveNamesWithLocalCache (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:82038:38)
    at Object.resolveModuleNames (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:82091:20)
    at ConfiguredProject.Project.resolveModuleNames (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:82678:45)
    at Object.compilerHost.resolveModuleNames (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:79713:117)
    at resolveModuleNamesWorker (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:58912:106)
    at resolveModuleNamesReusingOldState (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:59043:24)
    at processImportedModules (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:59954:35)
    at findSourceFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:59875:17)
    at args (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:59775:85)
    at getSourceFileFromReferenceWorker (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:59749:34)
    at processSourceFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:59775:13)
    at processTypeReferenceDirective (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:59910:21)
    at Object.createProgram (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:58950:21)
    at synchronizeHostData (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:79721:26)
    at Object.getProgram (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:79756:13)
    at TypeScriptServiceHost.get [as program] (/Users/kyliau/.vscode/extensions/nglangsvc/node_modules/angular_language_service/index.js:56823:50)
    at TypeScriptServiceHost.validate (/Users/kyliau/.vscode/extensions/nglangsvc/node_modules/angular_language_service/index.js:56840:27)
    at TypeScriptServiceHost.getAnalyzedModules (/Users/kyliau/.vscode/extensions/nglangsvc/node_modules/angular_language_service/index.js:56721:14)
    at TypeScriptServiceHost.ensureTemplateMap (/Users/kyliau/.vscode/extensions/nglangsvc/node_modules/angular_language_service/index.js:56877:40)
    at TypeScriptServiceHost.getTemplateReferences (/Users/kyliau/.vscode/extensions/nglangsvc/node_modules/angular_language_service/index.js:56698:14)
    at Object.getExternalFiles (/Users/kyliau/.vscode/extensions/nglangsvc/node_modules/angular_language_service/index.js:57207:27)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:83386:39
    at Object.flatMap (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:1561:25)
    at ConfiguredProject.getExternalFiles (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:83382:48)
    at ProjectService.createConfiguredProject (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:84417:70)
    at ProjectService.openClientFileWithNormalizedPath (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:84740:44)
    at IOSession.Session.openClientFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:86071:37)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:85303:31)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:86710:88
    at IOSession.Session.executeWithRequestId (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:86701:28)
    at IOSession.Session.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:86710:33)
    at IOSession.Session.onMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:86730:35)
    at Interface.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:87922:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

And the corresponding code in src/server/editorServices.ts createConfiguredProject() is:

const filesToAdd = projectOptions.files.concat(project.getExternalFiles());
this.addFilesToNonInferredProjectAndUpdateGraph(project,
                                                filesToAdd,
                                                fileNamePropertyReader,
                                                projectOptions.typeAcquisition);

Note that the typeAcquisition is set after the call to project.getExternalFiles().

We are not sure if this is a bug, or the Angular plugin is doing something it's not supposed to.

If this a bug, a simple bugfix is proposed in this PR: kyliau#1

Activity

  1. mhegazy commented on Nov 30, 2017

    @mhegazy
    Contributor

    Ryan Cavanaugh (@RyanCavanaugh) can you take a look.

  2. kyliau commented on Dec 1, 2017

    @kyliau
    ContributorAuthor

    If we don't include external files here, then it will not crash, but semantic diagnostics no longer get shown on the html files (other features like go to definition still works).

  3. added
    Domain: API
    on Dec 1, 2017
  4. listepo-alterpost commented on Jun 6, 2018

    @listepo-alterpost

    Hi, any news?

  5. kyliau commented on May 22, 2019

    @kyliau
    ContributorAuthor

    Closing this since it's no longer relevant.

  6. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDomain: API

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions