Skip to content

Commit

Permalink
Trusted Domains: Timeout filesystem access (#100419)
Browse files Browse the repository at this point in the history
* Adds a timeout for trying to resolve remotes

This needs a better fix, but for remote file systems that require auth this can cause issues if auth requires opening a url

* Reduce timeout

Co-authored-by: Eric Amodio <eamodio@microsoft.com>
  • Loading branch information
Jackson Kearl and Eric Amodio authored Jun 17, 2020
1 parent 78ea448 commit cd9ea64
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/vs/workbench/contrib/url/browser/trustedDomains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,18 @@ export function extractGitHubRemotesFromGitConfig(gitConfig: string): string[] {

async function getRemotes(fileService: IFileService, textFileService: ITextFileService, contextService: IWorkspaceContextService): Promise<string[]> {
const workspaceUris = contextService.getWorkspace().folders.map(folder => folder.uri);
const domains = await Promise.all<string[]>(workspaceUris.map(async workspaceUri => {
const path = workspaceUri.path;
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
const exists = await fileService.exists(uri);
if (!exists) {
return [];
}
const gitConfig = (await (textFileService.read(uri, { acceptTextOnly: true }).catch(() => ({ value: '' })))).value;
return extractGitHubRemotesFromGitConfig(gitConfig);
}));
const domains = await Promise.race([
new Promise<string[][]>(resolve => setTimeout(() => resolve([]), 250)),
Promise.all<string[]>(workspaceUris.map(async workspaceUri => {
const path = workspaceUri.path;
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
const exists = await fileService.exists(uri);
if (!exists) {
return [];
}
const gitConfig = (await (textFileService.read(uri, { acceptTextOnly: true }).catch(() => ({ value: '' })))).value;
return extractGitHubRemotesFromGitConfig(gitConfig);
}))]);

const set = domains.reduce((set, list) => list.reduce((set, item) => set.add(item), set), new Set<string>());
return [...set];
Expand Down

0 comments on commit cd9ea64

Please sign in to comment.