Expose TS server tracing (#110534)
* Add typescript.tsserver.enableTracing setting * Document typescript.tsserver.enableTracing setting
This commit is contained in:
parent
06be9f4029
commit
9195c9ab14
|
@ -197,6 +197,12 @@
|
|||
"description": "%typescript.implementationsCodeLens.enabled%",
|
||||
"scope": "window"
|
||||
},
|
||||
"typescript.tsserver.enableTracing": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "%typescript.tsserver.enableTracing%",
|
||||
"scope": "window"
|
||||
},
|
||||
"typescript.tsserver.log": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"typescript.tsdk.desc": "Specifies the folder path to the tsserver and lib*.d.ts files under a TypeScript install to use for IntelliSense, for example: `./node_modules/typescript/lib`.\n\n- When specified as a user setting, the TypeScript version from `typescript.tsdk` automatically replaces the built-in TypeScript version.\n- When specified as a workspace setting, `typescript.tsdk` allows you to switch to use that workspace version of TypeScript for IntelliSense with the `TypeScript: Select TypeScript version` command.\n\nSee the [TypeScript documentation](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-newer-typescript-versions) for more detail about managing TypeScript versions.",
|
||||
"typescript.disableAutomaticTypeAcquisition": "Disables automatic type acquisition. Automatic type acquisition fetches `@types` packages from npm to improve IntelliSense for external libraries.",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": "Enables prompting of users to use the TypeScript version configured in the workspace for Intellisense.",
|
||||
"typescript.tsserver.enableTracing": "Enables tracing TS server performance to a directory. These trace files can be used to diagnose TS Server performance issues. The log may contain file paths, source code, and other potentially sensitive information from your project.",
|
||||
"typescript.tsserver.log": "Enables logging of the TS server to a file. This log can be used to diagnose TS Server issues. The log may contain file paths, source code, and other potentially sensitive information from your project.",
|
||||
"typescript.tsserver.pluginPaths": "Additional paths to discover TypeScript Language Service plugins.",
|
||||
"typescript.tsserver.pluginPaths.item": "Either an absolute or relative path. Relative path will be resolved against workspace folder(s).",
|
||||
|
|
|
@ -128,7 +128,7 @@ export class TypeScriptServerSpawner {
|
|||
const apiVersion = version.apiVersion || API.defaultVersion;
|
||||
|
||||
const canceller = cancellerFactory.create(kind, this._tracer);
|
||||
const { args, tsServerLogFile } = this.getTsServerArgs(kind, configuration, version, apiVersion, pluginManager, canceller.cancellationPipeName);
|
||||
const { args, tsServerLogFile, tsServerTraceDirectory } = this.getTsServerArgs(kind, configuration, version, apiVersion, pluginManager, canceller.cancellationPipeName);
|
||||
|
||||
if (TypeScriptServerSpawner.isLoggingEnabled(configuration)) {
|
||||
if (tsServerLogFile) {
|
||||
|
@ -138,6 +138,14 @@ export class TypeScriptServerSpawner {
|
|||
}
|
||||
}
|
||||
|
||||
if (configuration.enableTsServerTracing) {
|
||||
if (tsServerTraceDirectory) {
|
||||
this._logger.info(`<${kind}> Trace directory: ${tsServerTraceDirectory}`);
|
||||
} else {
|
||||
this._logger.error(`<${kind}> Could not create trace directory`);
|
||||
}
|
||||
}
|
||||
|
||||
this._logger.info(`<${kind}> Forking...`);
|
||||
const process = this._factory.fork(version.tsServerPath, args, kind, configuration, this._versionManager);
|
||||
this._logger.info(`<${kind}> Starting...`);
|
||||
|
@ -173,9 +181,10 @@ export class TypeScriptServerSpawner {
|
|||
apiVersion: API,
|
||||
pluginManager: PluginManager,
|
||||
cancellationPipeName: string | undefined,
|
||||
): { args: string[], tsServerLogFile: string | undefined } {
|
||||
): { args: string[], tsServerLogFile: string | undefined, tsServerTraceDirectory: string | undefined } {
|
||||
const args: string[] = [];
|
||||
let tsServerLogFile: string | undefined;
|
||||
let tsServerTraceDirectory: string | undefined;
|
||||
|
||||
if (kind === TsServerProcessKind.Syntax) {
|
||||
if (apiVersion.gte(API.v401)) {
|
||||
|
@ -216,6 +225,13 @@ export class TypeScriptServerSpawner {
|
|||
}
|
||||
}
|
||||
|
||||
if (configuration.enableTsServerTracing && !isWeb()) {
|
||||
tsServerTraceDirectory = this._logDirectoryProvider.getNewLogDirectory();
|
||||
if (tsServerTraceDirectory) {
|
||||
args.push('--traceDirectory', tsServerTraceDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isWeb()) {
|
||||
const pluginPaths = this._pluginPathsProvider.getPluginPaths();
|
||||
|
||||
|
@ -251,7 +267,7 @@ export class TypeScriptServerSpawner {
|
|||
args.push('--validateDefaultNpmLocation');
|
||||
}
|
||||
|
||||
return { args, tsServerLogFile };
|
||||
return { args, tsServerLogFile, tsServerTraceDirectory };
|
||||
}
|
||||
|
||||
private static isLoggingEnabled(configuration: TypeScriptServiceConfiguration) {
|
||||
|
|
|
@ -102,6 +102,7 @@ export class TypeScriptServiceConfiguration {
|
|||
public readonly enablePromptUseWorkspaceTsdk: boolean;
|
||||
public readonly watchOptions: protocol.WatchOptions | undefined;
|
||||
public readonly includePackageJsonAutoImports: 'auto' | 'on' | 'off' | undefined;
|
||||
public readonly enableTsServerTracing: boolean;
|
||||
|
||||
public static loadFromWorkspace(): TypeScriptServiceConfiguration {
|
||||
return new TypeScriptServiceConfiguration();
|
||||
|
@ -124,6 +125,7 @@ export class TypeScriptServiceConfiguration {
|
|||
this.enablePromptUseWorkspaceTsdk = TypeScriptServiceConfiguration.readEnablePromptUseWorkspaceTsdk(configuration);
|
||||
this.watchOptions = TypeScriptServiceConfiguration.readWatchOptions(configuration);
|
||||
this.includePackageJsonAutoImports = TypeScriptServiceConfiguration.readIncludePackageJsonAutoImports(configuration);
|
||||
this.enableTsServerTracing = TypeScriptServiceConfiguration.readEnableTsServerTracing(configuration);
|
||||
}
|
||||
|
||||
public isEqualTo(other: TypeScriptServiceConfiguration): boolean {
|
||||
|
@ -210,4 +212,8 @@ export class TypeScriptServiceConfiguration {
|
|||
private static readEnablePromptUseWorkspaceTsdk(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('typescript.enablePromptUseWorkspaceTsdk', false);
|
||||
}
|
||||
|
||||
private static readEnableTsServerTracing(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('typescript.tsserver.enableTracing', false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue