Skip to content

Commit cd9ea64

Browse files
Jackson KearlEric Amodio
Jackson Kearl
and
Eric Amodio
authored
Trusted Domains: Timeout filesystem access (#100419)
* 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 <[email protected]>
1 parent 78ea448 commit cd9ea64

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/vs/workbench/contrib/url/browser/trustedDomains.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,18 @@ export function extractGitHubRemotesFromGitConfig(gitConfig: string): string[] {
144144

145145
async function getRemotes(fileService: IFileService, textFileService: ITextFileService, contextService: IWorkspaceContextService): Promise<string[]> {
146146
const workspaceUris = contextService.getWorkspace().folders.map(folder => folder.uri);
147-
const domains = await Promise.all<string[]>(workspaceUris.map(async workspaceUri => {
148-
const path = workspaceUri.path;
149-
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
150-
const exists = await fileService.exists(uri);
151-
if (!exists) {
152-
return [];
153-
}
154-
const gitConfig = (await (textFileService.read(uri, { acceptTextOnly: true }).catch(() => ({ value: '' })))).value;
155-
return extractGitHubRemotesFromGitConfig(gitConfig);
156-
}));
147+
const domains = await Promise.race([
148+
new Promise<string[][]>(resolve => setTimeout(() => resolve([]), 250)),
149+
Promise.all<string[]>(workspaceUris.map(async workspaceUri => {
150+
const path = workspaceUri.path;
151+
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
152+
const exists = await fileService.exists(uri);
153+
if (!exists) {
154+
return [];
155+
}
156+
const gitConfig = (await (textFileService.read(uri, { acceptTextOnly: true }).catch(() => ({ value: '' })))).value;
157+
return extractGitHubRemotesFromGitConfig(gitConfig);
158+
}))]);
157159

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

0 commit comments

Comments
 (0)