diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index 76fa6ef..43d5877 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -571,6 +571,7 @@ export class LocalGitProvider implements GitProvider, Disposable { : [RepositoryVisibility.Private, getVisibilityCacheKey(remotes)]; } + private _pendingRemoteVisibility = new Map>(); @debug({ args: { 0: r => r.url }, exit: r => `returned ${r[0]}` }) private async getRemoteVisibility( remote: GitRemote, @@ -589,14 +590,22 @@ export class LocalGitProvider implements GitProvider, Disposable { if (url == null) return [RepositoryVisibility.Private, remote]; // Check if the url returns a 200 status code + let promise = this._pendingRemoteVisibility.get(url); + if (promise == null) { + promise = fetch(url, { method: 'HEAD', agent: getProxyAgent() }); + this._pendingRemoteVisibility.set(url, promise); + } + try { - const rsp = await fetch(url, { method: 'HEAD', agent: getProxyAgent() }); + const rsp = await promise; if (rsp.ok) return [RepositoryVisibility.Public, remote]; Logger.debug(scope, `Response=${rsp.status}`); } catch (ex) { debugger; Logger.error(ex, scope); + } finally { + this._pendingRemoteVisibility.delete(url); } return [RepositoryVisibility.Private, remote]; }