angular / vscode-ng-language-service

Angular extension for Visual Studio Code
MIT License
775 stars 116 forks source link

ngcc process fails with vscode versions 1.62.1 and above #1565

Closed joeypedicini92 closed 2 years ago

joeypedicini92 commented 2 years ago

🐞 bug report

Is this a regression?

Yes, I am currently on v13.0.0, I don't remember when it started throwing this error. ### Description A clear and concise description of the problem... I'm getting a popup everytime tsconfig.json changes and angular language service starts. Happening in multiple Angular v12 repos ## Bug Type What does this bug affect

Reproduction

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Logs

Log file gives us deep insight into the behavior and performance of the extension. If the issue is a performance problem or an error occured, please provide the output of the log file below.

Set Angular Log level to verbose.


[Trace - 9:44:04 AM] Sending notification 'workspace/didChangeWatchedFiles'.
[Trace - 9:44:04 AM] Received notification 'angular/projectLoadingFinish'.
[Trace - 9:44:04 AM] Received notification '$/progress'.
[Trace - 9:44:05 AM] Received notification 'window/logMessage'.
[Error - 9:44:05 AM] Failed to run ngcc for /Users/joey/Repos/battleface-v2/tsconfig.json, language service may not operate correctly:
    ngcc for /Users/joey/Repos/battleface-v2/tsconfig.json returned exit code null, stderr: 
[Trace - 9:44:05 AM] Received notification '$/progress'.
[Trace - 9:44:05 AM] Received notification 'window/logMessage'.
[Info  - 9:44:05 AM] Enabling Ivy language service for /Users/joey/Repos/battleface-v2/tsconfig.json.


Screenshots

Screen Shot 2021-11-11 at 9 44 11 AM

🌍 Your Environment

Angular Version:



 12.2.7

Extension Version:



 v13.0.0

VSCode Version:



 Version: 1.62.1 (Universal)

Operating System:



 macOS 11.6

Anything else relevant?

atscott commented 2 years ago

@joeypedicini92 a few questions to help, as I have not been able to reproduce this myself:

joeypedicini92 commented 2 years ago

I can try to get a sample project together when I have a bit more time. But it happens as soon as I open a project in vscode.

I am using Ivy, however in the vscode angular language server settings if I disable Ivy, I no longer get these errors (but then type checking and everything seems to not work right)

dependencies are installed, using yarn

ngc worked

ngcc worked

for additional reference I'm using an Nx repo in one repo but the other is just a plain angular repo

smlombardi commented 2 years ago

This is happening to me as well, as of the Insider version release 11/10. Same specs. We have multiple projects in our repo, with a tsconfig.json at the root of the repo:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "src",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "module": "esnext",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2018", "dom"],
    "paths": {
      "@app/*": ["app/*"],
      "@shared/*": ["app/shared/*"],
      "@env/*": ["environments/*"],
      "pb-design-system": ["../dist/pb-design-system"],
      "pb-design-system/*": ["../dist/pb-design-system/*"]
    }
  }
}

and then in the main project where Angular is (and all the files), /client, we have tsconfig.app.json:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": ""
  },
  "files": [
    "main.ts",
    "polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}
clientsrcappsharedbadgesaccessibility-badge component ts β€” ng-designsystem-20211111_131531

I am also getting this error on all our other projects, which use Nx Workscapes. These consist of a series of libs, each of which has it's own tsconfig.json file and they all point to the main one at the root:

{
  "extends": "../../../tsconfig.base.json",
  "files": [],
  "include": [],
  "references": [
    {
      "path": "./tsconfig.lib.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ],
  "angularCompilerOptions": {
    "strictInjectionParameters": true,
    "strictTemplates": true
  }
}

Not sure if any of this matters, since it all worked fine like this up until 2 days ago when the error occurred.

FWIW, ngcc runs fine with the command ./node_modules/.bin/ngcc --tsconfig tsconfig.json

atscott commented 2 years ago

@smlombardi You mentioned this was working for you two days ago. What updates happened between then and now? If nobody can provide a reproduction, hopefully we can at least determine what version this started happening with. Can you try installing different versions of the language service extension to see if there is an older one that works? If not, then the issue may have been caused by an update to the libraries in your project and it would be good to find what update that was.

smlombardi commented 2 years ago

It happened after I updated Code to the insiders version that came out 2 days ago. It happened immediately on relaunch

atscott commented 2 years ago

@smlombardi Just to clarify, there were no other updates to the project or extension? Updating the Code version didn't result in an update to the vscode extension? I'll go grab the latest insider version now to see if I can reproduce this.

atscott commented 2 years ago

Okay, I have been able to isolate this to the vscode 1.62.1 release. The error does not occur in the 1.62.0 release. When updating to 1.62.1 with no other changes, the ngcc process fails.

atscott commented 2 years ago

We are still actively investigating this issue and are tracking https://github.com/microsoft/vscode/issues/136988 as the likely resolution.

In the meantime, the error we show does give the appropriate information. ngcc failed to run, which might cause the language service to not work correctly but can be resolved by npm/yarn run ngcc. Or if you are already running a dev server, ngcc likely already ran and you don't have to do anything.

atscott commented 2 years ago

Closing as resolved in the 1.62.3 release of VSCode.

angular-automatic-lock-bot[bot] commented 2 years ago

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.