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

Infinite loop of "The TypeScript language service died unexpectedly" #9215

Closed
ghost opened this issue Jul 13, 2016 · 37 comments
Closed

Infinite loop of "The TypeScript language service died unexpectedly" #9215

ghost opened this issue Jul 13, 2016 · 37 comments
Assignees
Labels
info-needed Issue requires more information from poster javascript JavaScript support issues typescript Typescript support issues

Comments

@ghost
Copy link

ghost commented Jul 13, 2016

  • VSCode Version: 1.3.1
  • OS Version: Microsoft Windows [Version 10.0.10586]

Steps to Reproduce:

  1. Uninstall VSCode
  2. Install VSCode
  3. Navigate to an empty directory
  4. Open VSCode
  5. Create a new file empty.ts

The error message "The TypeScript language service died unexpectedly 5 times in the last 5 Minutes. Please consider to open a bug report." repeatedly pops up.
My settings.json is an empty object.

The problem can be solved by adding "typescript.tsdk": "C:\\Program Files\\nodejs\\node_modules\\typescript\\lib" to settings.json. My global tsc --version is 2.0.0.

@dbaeumer dbaeumer added typescript Typescript support issues info-needed Issue requires more information from poster labels Aug 2, 2016
@dbaeumer
Copy link
Member

dbaeumer commented Aug 2, 2016

@Andy-MS where did you get 2.0.0 from. npm install typescript@2.0.0 doesn't install any usable typescript package.

@ghost
Copy link
Author

ghost commented Aug 2, 2016

2.0.0 was the version installed by npm install -g typescript@next back when I wrote this issue.
I just removed "typescript.tsdk" from my settings and an empty project is now working, but I'm still sporadically getting the above error. Is there anything I can do in such a situation to detect what caused it?

EDIT: I am now again able to reproduce the problem in an empty directory with a new file empty.ts. Not sure why I couldn't before. What can I do to diagnose this issue?

@dbaeumer
Copy link
Member

dbaeumer commented Aug 3, 2016

@Andy-MS does a non empty file work. If so does the status line in the right corner give some hint about the TS version used ?

And just to be super sure. You neither have a tsdk setting in the user nor in the workspace settings.

@ghost
Copy link
Author

ghost commented Aug 3, 2016

The workspace was just created (there is no .vscode, so there are no workspace settings. The status line just says "TypeScript". If I change the language to "TypeScript React" it still has this problem.
screenshot

@dbaeumer
Copy link
Member

dbaeumer commented Aug 4, 2016

@Andy-MS I have no clue why this happens since this works for me without problems. Did you choose a special install location for VS Code ? If not does C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\server\typescript\lib exist with a similar content ?

capture

@ghost
Copy link
Author

ghost commented Aug 4, 2016

Yes, that folder exists for me with the same files listed. And I can run:

C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\server\typescript\lib> Get-FileHash .\tsserver.js

Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
SHA256          53773E51F556335592A8BAAEDBE630DC029D85FA9BB689417B14E644D6668776       C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\server\typescript\lib\tsserver.js

@dbaeumer
Copy link
Member

dbaeumer commented Aug 4, 2016

OK. if you add a workspace setting and restart code afterwards do you still see the problem ?

     "typescript.tsdk": "C:\\Program Files (x86)\\Microsoft VS Code\\resources\\app\\extensions\\typescript\\server\\typescript\\lib"

@ghost
Copy link
Author

ghost commented Aug 4, 2016

Yes, with that as the only line in my settings.json (besides { and }) I still get the error.

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2016

@Andy-MS I have no idea what is going on. You have the correct version of the tsserver. Do you still see this with VS Code 1.4. If so, can I give you instruction on how to debug this?

@ghost
Copy link
Author

ghost commented Aug 8, 2016

I still get it with 1.4. I'd be happy to try debugging it.

@dbaeumer
Copy link
Member

dbaeumer commented Aug 9, 2016

Thanks for offering your help. You need to do the following:

  • install VS Code insider so that you have a second independent instance (https://code.visualstudio.com/insiders)
  • create a new empty workspace folder and open a command prompt on it. Start code from the command prompt using code.cmd --debugPluginHost
  • start the insider build
  • go to the debug viewlet and press the configure icon on the top to create a launch.json config file.
  • change the port in the Attach section to 5870
{
            "name": "Attach",
            "type": "node",
            "request": "attach",
            "port": 5870,
            "address": "localhost",
            "restart": false,
            "sourceMaps": false,
            "outDir": null,
            "localRoot": "${workspaceRoot}",
            "remoteRoot": null
        }
  • select the attach debug configuration from the drop down.
  • press the green arrow to attach
  • no open the file: C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\out\typescriptServiceClient.js in the insider build
  • set a breakpoint on line 172 and 176 (assuming using code 1.4)
  • create a new TS in code and wait until the breakpoint gets hit.
  • which breakpoint gets hit and if 172 what exception are you receiving ?

@dbaeumer
Copy link
Member

dbaeumer commented Aug 9, 2016

@Andy-MS is your workspace on a mounted SharePoint WebDav folder. If so this is a dup of #3860

@ghost
Copy link
Author

ghost commented Aug 9, 2016

I see line 176 getting hit (this is the one after childProcess.on('exit') and err is 7. (My sample directory is on my own hard drive, not sharepoint.)

@dbaeumer
Copy link
Member

dbaeumer commented Aug 9, 2016

That means the node process exits with error number 7. Still no clue why :-(

@dbaeumer
Copy link
Member

dbaeumer commented Aug 9, 2016

Since you see The TypeScript language service died unexpectedly 5 times in the last 5 Minutes.... the service at least runs for a minute. Can you confirm this. If so I will look into steps to debug the tsserver as well.

@ghost
Copy link
Author

ghost commented Aug 9, 2016

Despite the message, the error happens within a few seconds of running code . (where vscode was not already open) in the previously-created directory with just an empty a.ts in it.

@dbaeumer
Copy link
Member

@Andy-MS. Very strange :-(.

The easiest to track this down is to run and debug VS Code from source. How to do so is documented here: https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run-from-source.

Would you be willing to set this up. Otherwise I will add additional options to the next build to ease this.

@ghost
Copy link
Author

ghost commented Aug 23, 2016

Sorry, but I was unable to build on Windows (using the latest c++ devtools from visual studio gives errors with oniguruma) and the problem does not happen on linux, so it'll have to wait until the next build.

@dbaeumer
Copy link
Member

@Andy-MS that looks like the problem we started seeing when upgrading the C/C++ tooling with VS Update 3. We have worked around it by updating the node-gyp package npm is using to version 3.4.0. (We are currently blocked from upgrading npm itself to >=3.9, the latest comes with the fixed node-gyp.).

@dbaeumer
Copy link
Member

dbaeumer commented Nov 15, 2016

@Andy-MS can you still reproduce this?

@Sayan751
Copy link

Sayan751 commented Dec 2, 2016

@dbaeumer I am also facing the same issue. I have noticed that if VS Code is ran as administrator, the problem goes away. In every other case, it goes into the infinite loop.

I am using VS Code v1.7.2, Node v5.9.0, tsc v2.0.10 on Windows 10.

@dbaeumer
Copy link
Member

dbaeumer commented Dec 5, 2016

@Sayan751 strange. Works for me using an non administrator account.

One idea to better understand this is the following:

  • can you install TS somewhere else on your disk where you have read / write access using npm install typescript@2.0.10
  • use the typescript.tsdk setting to point VS Code to that TS installation. E.g. "typescript.tsdk": "C:/tmp/node_modules/typescript/lib"

Does that help?

@ghost
Copy link
Author

ghost commented Dec 5, 2016

I can't reproduce this any more with VSCode 1.7.2. I just get a message "Info | Version mismatch! global tsc (2.2.0-dev.20161118) != VS Code's language service (2.0.10). Inconsistent compile..."

@dbaeumer
Copy link
Member

dbaeumer commented Dec 6, 2016

@Andy-MS the version mismatch points to the fact that your global tsc version is 2.2.0-dev.20161118 and the VSC version is 2.0.10. Since you don't have the tsdk setting pointing to 2.2.0-dev.20161118 it might happend that running tsc in the terminal produces different errors than the language service inside VS Code (because they are different version). You can disable that check by pressing the 'Don't check again' button.

@Sayan751
Copy link

Sayan751 commented Dec 8, 2016

@dbaeumer I confirm, that this helps. Thank you for that.

use the typescript.tsdk setting to point VS Code to that TS installation. E.g. "typescript.tsdk": "C:/tmp/node_modules/typescript/lib"

I think this is the workaround for now.

@dbaeumer
Copy link
Member

dbaeumer commented Dec 8, 2016

@Sayan751 good to hear. Now we need to understand why TS is not running from the installation directory. Is there anything special. Have you installed VS Code into a special location ?

@Sayan751
Copy link

Sayan751 commented Dec 8, 2016

@dbaeumer I can't remember changing any default option during installation. On my machine the installation path is "C:\Program Files (x86)\Microsoft VS Code\Code.exe"

@dbaeumer
Copy link
Member

dbaeumer commented Dec 8, 2016

@Sayan751 is there anything in the TypeScript Output Channel (Ctrl+Shift+U) select TypeScript from the drop down?

@Sayan751
Copy link

Sayan751 commented Dec 8, 2016

@dbaeumer When I use the default typescript.tsdk location, I get the following error messages in TypeScript Output repetitively:

[Info  - 1:03:42 PM] Using tsserver from location: c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\node_modules\typescript\lib\tsserver.js
[Error - 1:03:43 PM] TSServer exited with code: 1
[Info  - 1:03:43 PM] Using tsserver from location: c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\node_modules\typescript\lib\tsserver.js
[Error - 1:03:43 PM] TSServer exited with code: 1

However, when I override the default typescript.tsdk with local typescript inside node_modules, the error message goes away, and it simply says:

[Info  - 1:03:44 PM] Using tsserver from location: C:\Path\To\My\Code\node_modules\typescript\lib\tsserver.js

and along with that the infinite loop of the pop-up stops.

@dbaeumer
Copy link
Member

dbaeumer commented Dec 8, 2016

@Sayan751 could you do the following in advance:

  • open a terminal (e.g. PowerShell)
  • set the environment variable TSS_LOG="-level verbose -file c:\tmp\server.log" (in PowerShell $env:TSS_LOG="-level verbose -file c:\tmp\server.log"). Adopt the file location accordingly
  • start VS Code from the terminal using code command

Can you provide the content of the log file.

@Sayan751
Copy link

Sayan751 commented Dec 9, 2016

@dbaeumer Please find the logs attached.

vs-code log.zip

@dbaeumer
Copy link
Member

dbaeumer commented Dec 9, 2016

@Sayan751 surprisingly there is nothing that points to a crash in the log. If I give you instructions would you be able to debug this a little. I have no clue why this is happening.

@dbaeumer
Copy link
Member

dbaeumer commented Dec 9, 2016

@mhegazy any idea how we could find out why the tsserver exits without being ask to do so.

@Sayan751
Copy link

Sayan751 commented Dec 9, 2016

@dbaeumer I would like to debug this. However, it may take some time to get back you. Additionally also attaching some latest logs.
logs.zip

@dbaeumer
Copy link
Member

@Sayan751 thanks for the logs. Will have a look. When you have time to help me with that please ping.

@Sayan751
Copy link

@dbaeumer ping

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 7, 2017

Closing since it sounds like the original issue has been resolved.

If you seeing a similar problem with VSCode 1.9+, please open a new bug and we will investigate.

Thanks

@mjbvz mjbvz closed this as completed Feb 7, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster javascript JavaScript support issues typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

4 participants