Skip to content

Commit b1d403f

Browse files
committed
🐛 fixes microsoft#24598
1 parent 6c59263 commit b1d403f

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
echo ''

extensions/git/src/askpass.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ export class Askpass implements Disposable {
1313

1414
private server: http.Server;
1515
private portPromise: Promise<number>;
16+
private enabled = true;
1617

1718
constructor() {
1819
this.server = http.createServer((req, res) => this.onRequest(req, res));
19-
this.server.listen(0, 'localhost');
2020

21-
this.portPromise = new Promise(c => {
22-
this.server.on('listening', () => c(this.server.address().port));
23-
});
24-
25-
this.server.on('error', err => console.error(err));
21+
try {
22+
this.server.listen(0);
23+
this.portPromise = new Promise(c => this.server.on('listening', () => c(this.server.address().port)));
24+
this.server.on('error', err => console.error(err));
25+
} catch (err) {
26+
this.enabled = false;
27+
}
2628
}
2729

2830
private onRequest(req: http.ServerRequest, res: http.ServerResponse): void {
@@ -53,14 +55,20 @@ export class Askpass implements Disposable {
5355
return await window.showInputBox(options) || '';
5456
}
5557

56-
getEnv(): Promise<any> {
57-
return this.portPromise.then(port => ({
58+
async getEnv(): Promise<any> {
59+
if (!this.enabled) {
60+
return {
61+
GIT_ASKPASS: path.join(__dirname, 'askpass-empty.sh')
62+
};
63+
}
64+
65+
return {
5866
ELECTRON_RUN_AS_NODE: '1',
5967
GIT_ASKPASS: path.join(__dirname, 'askpass.sh'),
6068
VSCODE_GIT_ASKPASS_NODE: process.execPath,
6169
VSCODE_GIT_ASKPASS_MAIN: path.join(__dirname, 'askpass-main.js'),
62-
VSCODE_GIT_ASKPASS_PORT: String(port)
63-
}));
70+
VSCODE_GIT_ASKPASS_PORT: String(await this.portPromise)
71+
};
6472
}
6573

6674
dispose(): void {

0 commit comments

Comments
 (0)