Skip to content

feat: support heap profile and snapshot capture for tsserver#299003

Open
deepak1556 wants to merge 3 commits intomainfrom
robo/add_tsserver_diagnostics
Open

feat: support heap profile and snapshot capture for tsserver#299003
deepak1556 wants to merge 3 commits intomainfrom
robo/add_tsserver_diagnostics

Conversation

@deepak1556
Copy link
Collaborator

No description provided.

@deepak1556 deepak1556 added this to the March 2026 milestone Mar 3, 2026
@deepak1556 deepak1556 requested a review from mjbvz March 3, 2026 16:36
@deepak1556 deepak1556 self-assigned this Mar 3, 2026
Copilot AI review requested due to automatic review settings March 3, 2026 16:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for configuring heap profiling and heap snapshot capture for the TypeScript language server (tsserver) running on Electron (desktop). It exposes three new VS Code settings to control Node.js diagnostic flags passed to the tsserver process.

Changes:

  • Adds TsServerHeapProfileConfiguration interface and three new fields (diagnosticDir, heapSnapshot, heapProfile) to TypeScriptServiceConfiguration, with corresponding reader methods in BaseServiceConfigurationProvider
  • Passes the new Node.js flags (--diagnostic-dir, --heapsnapshot-near-heap-limit, --heap-prof, --heap-prof-dir, --heap-prof-interval) to the tsserver process based on configuration
  • Registers three new VS Code settings (js/ts.tsserver.diagnosticDir, js/ts.tsserver.heapSnapshot, js/ts.tsserver.heapProfile) with schema definitions and NLS descriptions

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
extensions/typescript-language-features/src/tsServer/serverProcess.electron.ts Adds code to append new diagnostic/profiling flags to the Node.js exec args for tsserver
extensions/typescript-language-features/src/configuration/configuration.ts Adds TsServerHeapProfileConfiguration interface, three new config fields, and reader methods
extensions/typescript-language-features/package.nls.json Adds NLS string descriptions for the three new settings
extensions/typescript-language-features/package.json Registers three new VS Code configuration settings with schema and metadata

if (configuration.heapProfile.enabled) {
args.push('--heap-prof');
if (configuration.heapProfile.dir) {
args.push(`--heap-prof-dir=${configuration.heapProfile.dir}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work correctly if the path has spaces or special characters in it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes arguments are preserved, also Node.js does not perform any file path checks on the value so what we have here is good enough.

@deepak1556
Copy link
Collaborator Author

However, testing it found the current shutdown sequence is a forceful one with process.kill which does not flush heap profiles so I have added a graceful path with timeout to get the profiles.

@deepak1556
Copy link
Collaborator Author

Screen.Recording.2026-03-04.at.13.11.28.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants