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

Extension stops working after 30-60 minutes #1399

Closed
1 of 2 tasks
devhus opened this issue Jun 4, 2021 · 22 comments · Fixed by #1461
Closed
1 of 2 tasks

Extension stops working after 30-60 minutes #1399

devhus opened this issue Jun 4, 2021 · 22 comments · Fixed by #1461

Comments

@devhus
Copy link

devhus commented Jun 4, 2021

🐞 bug report

Is this a regression?

Yes, the previous version in which this bug was not present was: 11.2.14

Description

Just finished upgrading my project to Angular 12 with the Ng Language Service v12 the IntelliSense starts getting buggy,
After few minutes from Initializing Angular Language Features the awareness of variables and methods in the component's template stopped working
Hovering on a variable shows its type, but trying to get the props of that variable won't show anything like the image below.
Note that, reloading VSCode or restarting it will fix the issue for a few minutes after the extension is initialized, then the issue will start to take effect.

Also enabling the Legacy View Engine option won't fix it, it will even bug it more taking away those few minutes before the issue happens.

Bug Type

  • Angular Language Service VSCode extension
  • Angular Language Service server

Logs

(yes there is a lot of wired white spaces added to the logs for no reason, wasn't me who added it)
nglangsvc.log
nglangsvc.log

Screenshots

vscode

vscode1

when the issue happens and tries to Go to definition of a variable:
unknown

🌍 Your Environment

Angular Version:

 
Angular CLI: 12.0.3
Node: 14.16.1
Package Manager: npm 6.14.13
OS: win32 x64

Angular: 12.0.3
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, localize, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1200.3
@angular-devkit/build-angular   12.0.3
@angular-devkit/core            12.0.3
@angular-devkit/schematics      12.0.3
@schematics/angular             11.2.14
rxjs                            6.6.7
typescript                      4.2.4

Extension Version:


12.0.4

VSCode Version:


Version: 1.56.2 (user setup)
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:13:13.157Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.19042

Operating System:


Microsoft Windows 10 Pro
Version	10.0.19042 Build 19042

package.json:


{
  "name": "bnaturalia-frontend",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "ng-s": "node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve"
  },
  "private": true,
  "dependencies": {
    "@angular-slider/ngx-slider": "^2.0.3",
    "@angular/animations": "^12.0.3",
    "@angular/cdk": "^12.0.3",
    "@angular/common": "^12.0.3",
    "@angular/compiler": "^12.0.3",
    "@angular/core": "^12.0.3",
    "@angular/forms": "^12.0.3",
    "@angular/localize": "^12.0.3",
    "@angular/platform-browser": "^12.0.3",
    "@angular/platform-browser-dynamic": "^12.0.3",
    "@angular/router": "^12.0.3",
    "@ckeditor/ckeditor5-angular": "^2.0.1",
    "@ckeditor/ckeditor5-autosave": "^27.1.0",
    "@ckeditor/ckeditor5-build-classic": "^27.1.0",
    "@ckeditor/ckeditor5-build-inline": "^27.1.0",
    "@gilsdav/ngx-translate-router": "^3.1.6",
    "@gilsdav/ngx-translate-router-http-loader": "^1.1.2",
    "@mdi/font": "^5.9.55",
    "@ng-bootstrap/ng-bootstrap": "^9.1.0",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "^6.0.0",
    "@schematics/angular": "^11.2.14",
    "@sweetalert2/ngx-sweetalert2": "^9.0.0",
    "@syncfusion/ej2-angular-filemanager": "^19.1.66",
    "apexcharts": "^3.26.0",
    "bootstrap": "^5.0.0-beta3",
    "country-state-city": "^2.1.0",
    "currency-list": "^1.0.6",
    "iso-country-currency": "^0.5.3",
    "ng-apexcharts": "^1.5.9",
    "ngx-bootstrap-icons": "^1.4.5",
    "ngx-rangeslider-component": "^1.0.6",
    "rxjs": "~6.6.0",
    "sweetalert2": "^10.16.0",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^12.0.3",
    "@angular/cli": "^12.0.3",
    "@angular/compiler-cli": "^12.0.3",
    "@angular/language-service": "^12.0.3",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.20.14",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "^6.3.3",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "^4.2.4"
  }
}
@devhus devhus added the bug label Jun 4, 2021
@ashwingairola
Copy link

In my experience, this is also happening for input properties.

atscott added a commit to atscott/vscode-ng-language-service that referenced this issue Jun 8, 2021
The `TextEdit` is not meant to replace text to the right of the
position. Instead, `InsesrtReplaceEdit` should be used.

Reference discussion in LSP issue for examples on replacement vs
insertion range for `InsertReplaceEdit`:
microsoft/language-server-protocol#846

Fixes angular#1399

Note that the issue did not appear in the VE version of the extension
because it was only providing completions as inserts (they had
no `replacementSpan`).
atscott added a commit to atscott/vscode-ng-language-service that referenced this issue Jun 8, 2021
The `TextEdit` is not meant to replace text to the right of the
position. Instead, `InsesrtReplaceEdit` should be used.

Reference discussion in LSP issue for examples on replacement vs
insertion range for `InsertReplaceEdit`:
microsoft/language-server-protocol#846

Fixes angular#1399

Note that the issue did not appear in the VE version of the extension
because it was only providing completions as inserts (they had
no `replacementSpan`).
@xantari
Copy link

xantari commented Jun 9, 2021

I'm also receiving this issue, revert to 11.2.14 for the time being. Intellisense is very broken in 12.0.4 in HTML templates.

@atscott
Copy link
Collaborator

atscott commented Jun 10, 2021

@xantari @ashwingairola @devhus are any of you able to provide a project with a set of steps that reproduces this issue? I don't see anything in the logs. What could also be helpful is enabling either verbose or messages of the trace: server extension options and pasting some of the output here

Screen Shot 2021-06-09 at 5 09 32 PM

It should look like this:
image

This trace shows the requests going from the client to the Angular language server as well as the response back. If something is breaking there, hopefully we can see it in the output (i.e. messages aren't being sent for some reason).

@xantari
Copy link

xantari commented Jun 10, 2021

Example from 12.0.4 Angular Language Service in the attached project.

12.0.4 Trace.txt

Global angular tools installed are 12.0.3. Local project version is 11.2.0:

I know this because of this warning:
Your global Angular CLI version (12.0.3) is greater than your local version (11.2.0). The local Angular CLI version is used.

To repro, hover over products in product-list.component.html using 12.0.4 of the angular language tools and you won't get any intellisense.

Revert back to 11.2.14 and hover over the products item and you will get intellisense when you hover over the "products" variable in product-list.component.html

At 11.2.14 hovering over products I see the following:

image

This is the log from 11.2.14 where it works, you can see the output is a bit different:

11.2.14 Trace.txt

I've also noticed that I can get it to break in 11.2.14 as well by turning on the "angular.experimental-ivy": true flag. Did 12.0.4 of the language service perhaps turn that on by default and might explain why it's broken in 12.0.4, and also broken in 11.2.14 when the IVY flag is turned on?

Here are the source files I'm using:

APM.zip

@atscott
Copy link
Collaborator

atscott commented Jun 10, 2021

@xantari yes, Ivy became the default in v12. Can you share your tsconfig.json? The issue for your project here may be that you need to enable strictTemplates

@xantari
Copy link

xantari commented Jun 10, 2021

@atscott The tsconfig is in the APM.zip project example I attached above.

@adurmus
Copy link

adurmus commented Jun 10, 2021

same. navigation doesn't work from html to code page.

<button (click)="getItems()"> Get Items
If you click getItems() then hit F12 it takes you to method. Since the latest update it doesn't. rolled back to 11.1.3 to get it work.

@atscott
Copy link
Collaborator

atscott commented Jun 10, 2021

@xantari Ah, I see that now (I was on my phone last night after hours). I'm able to reproduce your issue as well in that project so I will be investigating this today. Thanks!

@devhus
Copy link
Author

devhus commented Jun 10, 2021

@xantari yes, Ivy became the default in v12. Can you share your tsconfig.json? The issue for your project here may be that you need to enable strictTemplates

Its enabled, i will be able to share a bugged project with you today's night if you still need it.

@atscott
Copy link
Collaborator

atscott commented Jun 10, 2021

@devhus - I think that would be helpful. I have identified the issue with @xantari's project. The first div isn't closed. Adding another close </div> at the end of the template fixes things. That said, our visitor logic should handle this case. It would be good to know if your issue is the same or something different.

@xantari

This comment has been minimized.

@atscott

This comment has been minimized.

atscott added a commit to atscott/angular that referenced this issue Jun 10, 2021
…se tag

Unclosed element tags are not assigned an `endSourceSpan` by the parser.
As a result, the visitor which determines the target node at a position
for the language service was unable to determine that a given position
was inside an unclosed parent. This happens because we update the
`endSourceSpan` of template/element nodes to be the end tag (and there
is not one for unclosed tags). Consequently, the visitor then cannot
match a position to any child node location.

This change updates the visitor logic to check if there are any
`children` of a template/element node and updates the end span to be the
end span of the last child. This allows our `isWithin` logic to identify
that a child position is within the unclosed parent.

Addresses one of the issues found during investigation of angular/vscode-ng-language-service#1399
@devhus
Copy link
Author

devhus commented Jun 11, 2021

@devhus - I think that would be helpful. I have identified the issue with @xantari's project. The first div isn't closed. Adding another close </div> at the end of the template fixes things. That said, our visitor logic should handle this case. It would be good to know if your issue is the same or something different.

that is a sample project(removed a lot of base code from the original project), it has some memory leak bug as well (in case that was what is causing the issue)
and as I mentioned in the report above, the issue does not happen right away in the project. after spending some time working on the issue will start to randomly happen but not before few minutes after Angular Language Features being Initialized.

t.zip

atscott added a commit to atscott/angular that referenced this issue Jun 11, 2021
…se tag

Unclosed element tags are not assigned an `endSourceSpan` by the parser.
As a result, the visitor which determines the target node at a position
for the language service was unable to determine that a given position
was inside an unclosed parent. This happens because we update the
`endSourceSpan` of template/element nodes to be the end tag (and there
is not one for unclosed tags). Consequently, the visitor then cannot
match a position to any child node location.

This change updates the visitor logic to check if there are any
`children` of a template/element node and updates the end span to be the
end span of the last child. This allows our `isWithin` logic to identify
that a child position is within the unclosed parent.

Addresses one of the issues found during investigation of angular/vscode-ng-language-service#1399
@atscott
Copy link
Collaborator

atscott commented Jun 11, 2021

@devhus - I played around with the example project and wasn't able to reproduce the issue. There was a fix for autocompletion in the release yesterday. Could you update your extension to see if that resolves your issue?

atscott added a commit to atscott/angular that referenced this issue Jun 11, 2021
…se tag

Unclosed element tags are not assigned an `endSourceSpan` by the parser.
As a result, the visitor which determines the target node at a position
for the language service was unable to determine that a given position
was inside an unclosed parent. This happens because we update the
`endSourceSpan` of template/element nodes to be the end tag (and there
is not one for unclosed tags). Consequently, the visitor then cannot
match a position to any child node location.

This change updates the visitor logic to check if there are any
`children` of a template/element node and updates the end span to be the
end span of the last child. This allows our `isWithin` logic to identify
that a child position is within the unclosed parent.

Addresses one of the issues found during investigation of angular/vscode-ng-language-service#1399
atscott added a commit to atscott/angular that referenced this issue Jun 11, 2021
…se tag

Unclosed element tags are not assigned an `endSourceSpan` by the parser.
As a result, the visitor which determines the target node at a position
for the language service was unable to determine that a given position
was inside an unclosed parent. This happens because we update the
`endSourceSpan` of template/element nodes to be the end tag (and there
is not one for unclosed tags). Consequently, the visitor then cannot
match a position to any child node location.

This change updates the visitor logic to check if there are any
`children` of a template/element node and updates the end span to be the
end span of the last child. This allows our `isWithin` logic to identify
that a child position is within the unclosed parent.

Addresses one of the issues found during investigation of angular/vscode-ng-language-service#1399
@devhus
Copy link
Author

devhus commented Jun 12, 2021

@devhus - I played around with the example project and wasn't able to reproduce the issue. There was a fix for autocompletion in the release yesterday. Could you update your extension to see if that resolves your issue?

You need to leave it open for some time. Open the project through workspace.code-workspace file then ng serve it, and leave the project opened in your taskbar for about 30-60 minutes and the issue will randomly happen, hopfully.
Unfortunately, the issue was not fixed for me with the last update.

@atscott atscott changed the title Component's template variables and methods IntelliSense is bugged Extension stops working after 30-60 minutes Jun 14, 2021
alxhub pushed a commit to angular/angular that referenced this issue Jun 14, 2021
…se tag (#42554)

Unclosed element tags are not assigned an `endSourceSpan` by the parser.
As a result, the visitor which determines the target node at a position
for the language service was unable to determine that a given position
was inside an unclosed parent. This happens because we update the
`endSourceSpan` of template/element nodes to be the end tag (and there
is not one for unclosed tags). Consequently, the visitor then cannot
match a position to any child node location.

This change updates the visitor logic to check if there are any
`children` of a template/element node and updates the end span to be the
end span of the last child. This allows our `isWithin` logic to identify
that a child position is within the unclosed parent.

Addresses one of the issues found during investigation of angular/vscode-ng-language-service#1399

PR Close #42554
alxhub pushed a commit to angular/angular that referenced this issue Jun 14, 2021
…se tag (#42554)

Unclosed element tags are not assigned an `endSourceSpan` by the parser.
As a result, the visitor which determines the target node at a position
for the language service was unable to determine that a given position
was inside an unclosed parent. This happens because we update the
`endSourceSpan` of template/element nodes to be the end tag (and there
is not one for unclosed tags). Consequently, the visitor then cannot
match a position to any child node location.

This change updates the visitor logic to check if there are any
`children` of a template/element node and updates the end span to be the
end span of the last child. This allows our `isWithin` logic to identify
that a child position is within the unclosed parent.

Addresses one of the issues found during investigation of angular/vscode-ng-language-service#1399

PR Close #42554
@Nness

This comment has been minimized.

@atscott

This comment has been minimized.

@atscott
Copy link
Collaborator

atscott commented Jun 15, 2021

@devhus - I have left the application running with ng serve for the past two days and have not encountered an issue. I'll leave this open for now to see if others are experiencing the same and can provide a reproduction but will probably end up closing it at some point in the future since we can't reproduce it.

@devhus
Copy link
Author

devhus commented Jun 15, 2021

@devhus - I have left the application running with ng serve for the past two days and have not encountered an issue. I'll leave this open for now to see if others are experiencing the same and can provide a reproduction but will probably end up closing it at some point in the future since we can't reproduce it.

Well, do you notice any memory leak in the project? (Nodejs runtime thread in your task manager will have about 1.5GB ram usage as you're serving the project and the memory usage keep increasing until your serve session is crashed)
if you don't have any issues with the memory causing the served session to be shutdown and throwing this error JavaScript heap out of memory while running ng serve then the real issue might be in my environment(pc win-10) but, I have no idea how to check this out.

@atscott
Copy link
Collaborator

atscott commented Jun 15, 2021

@devhus It sounds like this may potentially be angular/angular-cli#20801. If that's the case, then the issue is with the cli and is being tracked there.

@jpike88
Copy link

jpike88 commented Jul 21, 2021

may also be related to #1421

atscott added a commit to atscott/vscode-ng-language-service that referenced this issue Jul 28, 2021
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 angular#1438
Fixes angular#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.
atscott added a commit to atscott/vscode-ng-language-service that referenced this issue Jul 28, 2021
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 angular#1438
Fixes angular#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.
atscott added a commit that referenced this issue Jul 28, 2021
…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.
atscott added a commit that referenced this issue Jul 28, 2021
…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.

(cherry picked from commit 30c4996)
@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 Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
7 participants