Skip to content

Commit 4580803

Browse files
committed
Cache proxy only per scheme://host:port (microsoft#60773)
1 parent 2eae360 commit 4580803

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/vs/workbench/node/proxyResolver.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function connectProxyResolver(
2929
return configureModuleLoading(extensionService, lookup);
3030
}
3131

32-
const maxCacheEntries = 10000;
32+
const maxCacheEntries = 5000; // Cache can grow twice that much due to 'oldCache'.
3333

3434
function createProxyAgent(
3535
extHostWorkspace: ExtHostWorkspace,
@@ -50,9 +50,11 @@ function createProxyAgent(
5050
let oldCache = new Map<string, string>();
5151
let cache = new Map<string, string>();
5252
function getCacheKey(url: string) {
53-
// Expecting proxies to usually be the same per host. Keeping the path in for now.
54-
const queryIndex = url.indexOf('?');
55-
return queryIndex === -1 ? url : url.substr(0, queryIndex);
53+
// Expecting proxies to usually be the same per scheme://host:port. Assuming that for performance.
54+
const parsed = nodeurl.parse(url); // Coming from Node's URL, sticking with that.
55+
delete parsed.pathname;
56+
delete parsed.search;
57+
return nodeurl.format(parsed);
5658
}
5759
function getCachedProxy(key: string) {
5860
let proxy = cache.get(key);

0 commit comments

Comments
 (0)