Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@angular/language-service gets loaded from wrong location #437

Closed
andrius-pra opened this issue Nov 10, 2019 · 9 comments · Fixed by #448
Closed

@angular/language-service gets loaded from wrong location #437

andrius-pra opened this issue Nov 10, 2019 · 9 comments · Fixed by #448
Labels

Comments

@andrius-pra
Copy link
Collaborator

Steps to reproduce:

  1. Install angular.ng-template-0.900.0-rc.0 extension.
  2. install latest angular cli: npm install -g @angular/cli
  3. create new angular project ng new demo
  4. open new project in vscode cd demo & code .
  5. open app.component.html. you will get No config file for app.component.html error in output window:
[Info  - 17:56:40] Using typescript v3.5.3 from e:\demo\demo\node_modules\typescript
[Info  - 17:56:40] Using @angular/language-service v9.0.0-rc.0 from c:\Users\Andrius\.vscode\extensions\angular.ng-template-0.900.0-rc.0\server\node_modules\@angular\language-service
[Info  - 17:56:40] Log file: c:\Users\Andrius\AppData\Roaming\Code\logs\20191110T175635\exthost1\Angular.ng-template\nglangsvc.log
[Error - 17:56:44] No config file for e:\demo\demo\src\app\app.component.html
  1. open app.component.ts
  2. open again app.component.html
  3. you will get popup: The Angular Language Service server crashed 5 times in the last 3 minutes. The server will not be restarted. popup and this error in output window.
e:\demo\demo\node_modules\typescript\lib\tsserverlibrary.js:122228
                throw new Error("Could not find sourceFile: '" + fileName + "' in " + (program && JSON.stringify(program.getSourceFiles().map(function (f) { return f.fileName; }))) + ".");
                ^
Error: Could not find sourceFile: 'e:/demo/demo/src/app/app.component.html' in
at getValidSourceFile (e:\demo\demo\node_modules\typescript\lib\tsserverlibrary.js:122228:23)
    at Object.getSemanticDiagnostics (e:\demo\demo\node_modules\typescript\lib\tsserverlibrary.js:122430:36)
    at Object.proxy.getSemanticDiagnostics (e:\demo\demo\node_modules\@angular\language-service\bundles\language-service.umd.js:49429:32)
    at Session.sendPendingDiagnostics (c:\Users\Andrius\.vscode\extensions\angular.ng-template-0.900.0-rc.0\server\index.js:792:39)
    at Timeout._onTimeout (c:\Users\Andrius\.vscode\extensions\angular.ng-template-0.900.0-rc.0\server\index.js:772:19)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

angular

@ayazhafiz ayazhafiz added the bug label Nov 10, 2019
@kyliau
Copy link
Contributor

kyliau commented Nov 11, 2019

Looking at the logs, I think this is due to microsoft/TypeScript#34616

Even though we resolved the location of @angular/language-service and asked tsserver to load the plugin from that location, tsserver would look in typescript's peer node_modules before using the path we provide. If it finds one, it'd use that over the one we passed in.

I deduce this based on the line language-service.umd.js:49429
This must be using an older version of the language service that does not support angularOnly config.

@kyliau
Copy link
Contributor

kyliau commented Nov 11, 2019

@andrius-pra, could you please manually inspect the version in e:\demo\demo\node_modules\@angular\language-service\package.json?

Another way to confirm this:
The console says:

Using @angular/language-service v9.0.0-rc.0 from c:\Users\Andrius\.vscode\extensions\angular.ng-template-0.900.0-rc.0\server\node_modules\@angular\language-service

but the stack trace shows a different location.

    at Object.proxy.getSemanticDiagnostics (e:\demo\demo\node_modules\@angular\language-service\bundles\language-service.umd.js:49429:32)

@kyliau kyliau changed the title The Angular Language Service server crashed 5 times in the last 3 minutes. The server will not be restarted. @angular/language-service gets loaded from wrong location Nov 11, 2019
@kyliau
Copy link
Contributor

kyliau commented Nov 11, 2019

Maybe the solution here is to invert the default? We load TS and Angular from the bundled location, but provide users with an option load from workspace.
This means we could avoid nasty surprises like this (and the no config found for HTML bug), but it could introduce inconsistency between user's workspace version vs the bundled version.

@ayazhafiz
Copy link
Member

I think we should leave probing the workspace version as being the default.

@andrius-pra
Copy link
Collaborator Author

@andrius-pra, could you please manually inspect the version in e:\demo\demo\node_modules\@angular\language-service\package.json?

Angular CLI: 8.3.18
Node: 12.13.0
OS: win32 x64
Angular: 8.2.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.18
@angular-devkit/build-angular     0.803.18
@angular-devkit/build-optimizer   0.803.18
@angular-devkit/build-webpack     0.803.18
@angular-devkit/core              8.3.18
@angular-devkit/schematics        8.3.18
@angular/cli                      8.3.18
@ngtools/webpack                  8.3.18
@schematics/angular               8.3.18
@schematics/update                0.803.18
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2

@kyliau
Copy link
Contributor

kyliau commented Nov 12, 2019

yeah, it's v8.2.13. I guess we'll have to wait for TypeScript to release the change I made. Does anyone know if they're gonna backport the commit to older versions?

@andrius-pra
Copy link
Collaborator Author

typescript 3.7.2 is already released and it contains your change.

@kyliau
Copy link
Contributor

kyliau commented Nov 22, 2019

It looks like the change is not yet in ts 3.7.2
I checked the tag in the commit, there's none.
I also inspected the source code (warning: large file!), and searched for peer node_modules, it's still the old behavior.

kyliau added a commit to kyliau/vscode-ng-language-service that referenced this issue Nov 23, 2019
ayazhafiz pushed a commit that referenced this issue Nov 24, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants