Skip to content

Commit e71c429

Browse files
committed
address pr comment
1 parent 2bc8da8 commit e71c429

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/vs/platform/remote/electron-sandbox/remoteAuthorityResolverService.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot
2222

2323
private readonly _resolveAuthorityRequests: Map<string, DeferredPromise<ResolverResult>>;
2424
private readonly _connectionTokens: Map<string, string>;
25-
private readonly _canonicalURIRequests: Map<string, DeferredPromise<URI>>;
25+
private readonly _canonicalURIRequests: Map<string, { input: URI; result: DeferredPromise<URI> }>;
2626
private _canonicalURIProvider: ((uri: URI) => Promise<URI>) | null;
2727

2828
constructor(@IProductService productService: IProductService) {
2929
super();
3030
this._resolveAuthorityRequests = new Map<string, DeferredPromise<ResolverResult>>();
3131
this._connectionTokens = new Map<string, string>();
32-
this._canonicalURIRequests = new Map<string, DeferredPromise<URI>>();
32+
this._canonicalURIRequests = new Map();
3333
this._canonicalURIProvider = null;
3434

3535
RemoteAuthorities.setServerRootPath(getRemoteServerRootPath(productService));
@@ -44,12 +44,15 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot
4444

4545
async getCanonicalURI(uri: URI): Promise<URI> {
4646
const key = uri.toString();
47-
if (!this._canonicalURIRequests.has(key)) {
48-
const request = new DeferredPromise<URI>();
49-
this._canonicalURIProvider?.(uri).then((uri) => request.complete(uri), (err) => request.error(err));
50-
this._canonicalURIRequests.set(key, request);
47+
const existing = this._canonicalURIRequests.get(key);
48+
if (existing) {
49+
return existing.result.p;
5150
}
52-
return this._canonicalURIRequests.get(key)!.p;
51+
52+
const result = new DeferredPromise<URI>();
53+
this._canonicalURIProvider?.(uri).then((uri) => result.complete(uri), (err) => result.error(err));
54+
this._canonicalURIRequests.set(key, { input: uri, result });
55+
return result.p;
5356
}
5457

5558
getConnectionData(authority: string): IRemoteConnectionData | null {
@@ -105,8 +108,8 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot
105108

106109
_setCanonicalURIProvider(provider: (uri: URI) => Promise<URI>): void {
107110
this._canonicalURIProvider = provider;
108-
this._canonicalURIRequests.forEach((value, key) => {
109-
this._canonicalURIProvider!(URI.parse(key)).then((uri) => value.complete(uri), (err) => value.error(err));
111+
this._canonicalURIRequests.forEach(({ result, input }) => {
112+
this._canonicalURIProvider!(input).then((uri) => result.complete(uri), (err) => result.error(err));
110113
});
111114
}
112115
}

0 commit comments

Comments
 (0)