Fixing cancellation errors for TS. Fixes #28501

This commit is contained in:
Matt Bierner 2017-06-12 15:27:37 -07:00
parent 78250b41d2
commit 01fa0b83e9
2 changed files with 12 additions and 4 deletions

View file

@ -497,7 +497,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
args.push('--enableTelemetry');
}
if (this.apiVersion.has222Features()) {
this.cancellationPipeName = electron.getPipeName(`tscancellation-${electron.makeRandomHexString(20)}`);
this.cancellationPipeName = electron.getTempFile(`tscancellation-${electron.makeRandomHexString(20)}`);
args.push('--cancellationPipeName', this.cancellationPipeName + '*');
}
@ -947,7 +947,11 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
if (this.apiVersion.has222Features() && this.cancellationPipeName) {
this.tracer.logTrace(`TypeScript Service: trying to cancel ongoing request with sequence number ${seq}`);
fs.writeFileSync(this.cancellationPipeName + seq, '');
try {
fs.writeFileSync(this.cancellationPipeName + seq, '');
} catch (e) {
// noop
}
return true;
}

View file

@ -27,8 +27,7 @@ export function makeRandomHexString(length: number): string {
function generatePipeName(): string {
return getPipeName(makeRandomHexString(40));
}
export function getPipeName(name: string): string {
function getPipeName(name: string): string {
const fullName = 'vscode-' + name;
if (process.platform === 'win32') {
return '\\\\.\\pipe\\' + fullName + '-sock';
@ -38,6 +37,11 @@ export function getPipeName(name: string): string {
return path.join(os.tmpdir(), fullName + '.sock');
}
export function getTempFile(name: string): string {
const fullName = 'vscode-' + name;
return path.join(os.tmpdir(), fullName + '.sock');
}
function generatePatchedEnv(env: any, stdInPipeName: string, stdOutPipeName: string, stdErrPipeName: string): any {
// Set the two unique pipe names and the electron flag as process env