mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
Use uris instead of string paths for TS Server logs (#172872)
This commit is contained in:
@@ -14,11 +14,11 @@ export class NodeLogDirectoryProvider implements ILogDirectoryProvider {
|
||||
private readonly context: vscode.ExtensionContext
|
||||
) { }
|
||||
|
||||
public getNewLogDirectory(): string | undefined {
|
||||
public getNewLogDirectory(): vscode.Uri | undefined {
|
||||
const root = this.logDirectory();
|
||||
if (root) {
|
||||
try {
|
||||
return fs.mkdtempSync(path.join(root, `tsserver-log-`));
|
||||
return vscode.Uri.file(fs.mkdtempSync(path.join(root, `tsserver-log-`)));
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export interface ILogDirectoryProvider {
|
||||
getNewLogDirectory(): string | undefined;
|
||||
getNewLogDirectory(): vscode.Uri | undefined;
|
||||
}
|
||||
|
||||
export const noopLogDirectoryProvider = new class implements ILogDirectoryProvider {
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface ITypeScriptServer {
|
||||
readonly onExit: vscode.Event<TypeScriptServerExitEvent>;
|
||||
readonly onError: vscode.Event<any>;
|
||||
|
||||
readonly tsServerLogFile: string | undefined;
|
||||
readonly tsServerLogFile: vscode.Uri | undefined;
|
||||
|
||||
kill(): void;
|
||||
|
||||
@@ -89,7 +89,7 @@ export class ProcessBasedTsServer extends Disposable implements ITypeScriptServe
|
||||
private readonly _serverId: string,
|
||||
private readonly _serverSource: ServerType,
|
||||
private readonly _process: TsServerProcess,
|
||||
private readonly _tsServerLogFile: string | undefined,
|
||||
private readonly _tsServerLogFile: vscode.Uri | undefined,
|
||||
private readonly _requestCanceller: OngoingRequestCanceller,
|
||||
private readonly _version: TypeScriptVersion,
|
||||
private readonly _telemetryReporter: TelemetryReporter,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import { OngoingRequestCancellerFactory } from '../tsServer/cancellation';
|
||||
import { ClientCapabilities, ClientCapability, ServerType } from '../typescriptService';
|
||||
@@ -187,10 +186,10 @@ export class TypeScriptServerSpawner {
|
||||
apiVersion: API,
|
||||
pluginManager: PluginManager,
|
||||
cancellationPipeName: string | undefined,
|
||||
): { args: string[]; tsServerLogFile: string | undefined; tsServerTraceDirectory: string | undefined } {
|
||||
): { args: string[]; tsServerLogFile: vscode.Uri | undefined; tsServerTraceDirectory: vscode.Uri | undefined } {
|
||||
const args: string[] = [];
|
||||
let tsServerLogFile: string | undefined;
|
||||
let tsServerTraceDirectory: string | undefined;
|
||||
let tsServerLogFile: vscode.Uri | undefined;
|
||||
let tsServerTraceDirectory: vscode.Uri | undefined;
|
||||
|
||||
if (kind === TsServerProcessKind.Syntax) {
|
||||
if (apiVersion.gte(API.v401)) {
|
||||
@@ -220,9 +219,10 @@ export class TypeScriptServerSpawner {
|
||||
} else {
|
||||
const logDir = this._logDirectoryProvider.getNewLogDirectory();
|
||||
if (logDir) {
|
||||
tsServerLogFile = path.join(logDir, `tsserver.log`);
|
||||
tsServerLogFile = vscode.Uri.joinPath(logDir, `tsserver.log`);
|
||||
|
||||
args.push('--logVerbosity', TsServerLogLevel.toString(configuration.tsServerLogLevel));
|
||||
args.push('--logFile', tsServerLogFile);
|
||||
args.push('--logFile', tsServerLogFile.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ export class TypeScriptServerSpawner {
|
||||
if (configuration.enableTsServerTracing && !isWeb()) {
|
||||
tsServerTraceDirectory = this._logDirectoryProvider.getNewLogDirectory();
|
||||
if (tsServerTraceDirectory) {
|
||||
args.push('--traceDirectory', tsServerTraceDirectory);
|
||||
args.push('--traceDirectory', tsServerTraceDirectory.path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace ServerState {
|
||||
readonly type = Type.Errored;
|
||||
constructor(
|
||||
public readonly error: Error,
|
||||
public readonly tsServerLogFile: string | undefined,
|
||||
public readonly tsServerLogFile: vscode.Uri | undefined,
|
||||
) { }
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
|
||||
try {
|
||||
const doc = await vscode.workspace.openTextDocument(vscode.Uri.file(this.serverState.server.tsServerLogFile));
|
||||
const doc = await vscode.workspace.openTextDocument(this.serverState.server.tsServerLogFile);
|
||||
await vscode.window.showTextDocument(doc);
|
||||
return true;
|
||||
} catch {
|
||||
@@ -525,7 +525,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
|
||||
try {
|
||||
await vscode.commands.executeCommand('revealFileInOS', vscode.Uri.file(this.serverState.server.tsServerLogFile));
|
||||
await vscode.commands.executeCommand('revealFileInOS', this.serverState.server.tsServerLogFile);
|
||||
return true;
|
||||
} catch {
|
||||
vscode.window.showWarningMessage(vscode.l10n.t("Could not open TS Server log file"));
|
||||
@@ -1020,7 +1020,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
|
||||
function getReportIssueArgsForError(
|
||||
error: TypeScriptServerError,
|
||||
logPath: string | undefined,
|
||||
logPath: vscode.Uri | undefined,
|
||||
globalPlugins: readonly TypeScriptServerPlugin[],
|
||||
): { extensionId: string; issueTitle: string; issueBody: string } | undefined {
|
||||
if (!error.serverStack || !error.serverMessage) {
|
||||
@@ -1055,7 +1055,7 @@ function getReportIssueArgsForError(
|
||||
|
||||
❗️ Please review and upload this log file to help us diagnose this crash:
|
||||
|
||||
\`${logPath}\`
|
||||
\`${logPath.fsPath}\`
|
||||
|
||||
The log file may contain personal data, including full paths and source code from your workspace. You can scrub the log file to remove paths or other personal information.
|
||||
`);
|
||||
|
||||
Reference in New Issue
Block a user