Step-by-Step Guide to Collect and Analyze TS Server Crash Logs in Visual Studio Code

Often times, when working with Typescript in the Visual Studio Code (VS Code) editor, we can experience sudden crashes or unexpected behavior. In such cases, the Typescript Server logs can provide useful insights to better understand the issue and carry out troubleshooting effectively. This blog post will guide you step-by-step on how you can collect the TS server log from a crashed instance in a VS Code environment.

Prerequisites

Before we proceed, make sure that the following conditions are met:

  1. VS Code is installed on your system.
  2. The Typescript extension is installed and enabled on your VS Code editor.

Collecting TS Server log

First, you need to set the typescript.tsserver.log to verbose. This is done to ensure that the log level includes all detail. Here is how you do it:

  1. Open VS Code.
  2. Go to settings by clicking the gear icon at the bottom left.
  3. Search for typescript.tsserver.log.
  4. Change the setting to verbose.

Now that the log level has been set to verbose, next you should reproduce the problem that led to the crash.

Finding the Error Log File

After reproducing the problem and experiencing the crash, the next step is to locate the first line that prints the path to the semantic error log file. It will look something like this:

[Info - 19:54:59.247] <semantic> Log file: /Users/matb/Library/Application Support/Code - Insiders/logs/20200213T104930/exthost55/vscode.typescript-language-features/tsserver-log-ZT2zau/tsserver.log

This states the path to the semantic typescript log which contains error logs and potential clues to resolve the problem.

Analysing the Log File

Once you obtain the path to the log file as shown in the example above, open the respective log file. Skim through the log file to find the first error or stack trace. This will give you an indication of where things went wrong.

You can also share the log file for advice and suggestions from others. Having someone else take a second look at your log file could lead to a faster resolution as they may catch something you might have overlooked.

Note

When adding images to the comment section to clarify any points, use the format “, where alt will serve as the title for the image and url is the link to the image. The image URL should be a valid image link you have. Please do not use arbitrary URLs.

Conclusion

That’s it! By following this guide, you should now be able to collect TS Server Logs from a crashed instance and find possible error origins to troubleshoot Typescript server crashes in VS Code.

Tags: Technology, Programming, Typescript, Visual Studio Code

[Reference Link](!https://github.com/microsoft/vscode/issues/171156)