Skip to content

Commit ee58271

Browse files
committed
git: cleanup ipc handles on deactivate
related to microsoft#7758
1 parent 11073ce commit ee58271

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

extensions/git/src/askpass.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { denodeify } from './util';
1010
import * as path from 'path';
1111
import * as http from 'http';
1212
import * as os from 'os';
13+
import * as fs from 'fs';
1314
import * as crypto from 'crypto';
1415

1516
const randomBytes = denodeify<Buffer>(crypto.randomBytes);
@@ -38,6 +39,7 @@ export class Askpass implements Disposable {
3839

3940
private server: http.Server;
4041
private ipcHandlePathPromise: Promise<string>;
42+
private ipcHandlePath: string | undefined;
4143
private enabled = true;
4244

4345
constructor() {
@@ -52,6 +54,7 @@ export class Askpass implements Disposable {
5254
const buffer = await randomBytes(20);
5355
const nonce = buffer.toString('hex');
5456
const ipcHandlePath = getIPCHandlePath(nonce);
57+
this.ipcHandlePath = ipcHandlePath;
5558

5659
try {
5760
this.server.listen(ipcHandlePath);
@@ -110,5 +113,9 @@ export class Askpass implements Disposable {
110113

111114
dispose(): void {
112115
this.server.close();
116+
117+
if (this.ipcHandlePath && process.platform !== 'win32') {
118+
fs.unlinkSync(this.ipcHandlePath);
119+
}
113120
}
114121
}

extensions/git/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ async function init(context: ExtensionContext, outputChannel: OutputChannel, dis
2525
const pathHint = workspace.getConfiguration('git').get<string>('path');
2626
const info = await findGit(pathHint, path => outputChannel.appendLine(localize('looking', "Looking for git in: {0}", path)));
2727
const askpass = new Askpass();
28+
disposables.push(askpass);
29+
2830
const env = await askpass.getEnv();
2931
const git = new Git({ gitPath: info.path, version: info.version, env });
3032
const model = new Model(git, context.globalState, outputChannel);

0 commit comments

Comments
 (0)