Skip to content

Commit e48b99f

Browse files
committed
Cleanup (DH-18086-2)
1 parent 9dee1bd commit e48b99f

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/controllers/ExtensionController.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -348,24 +348,22 @@ export class ExtensionController implements Disposable {
348348
const workerInfo = await this._serverManager?.getWorkerInfo(
349349
url as WorkerURL
350350
);
351-
352-
const dhc = await this._coreJsApiCache.get(url);
353-
354-
const clientUrl = workerInfo == null ? url : workerInfo.grpcUrl;
355351
const envoyPrefix = workerInfo?.envoyPrefix;
352+
const urlStr = String(workerInfo?.grpcUrl ?? url).replace(/\/$/, '');
356353

357-
const headers: { [key: string]: string } =
358-
// eslint-disable-next-line @typescript-eslint/naming-convention
359-
envoyPrefix == null ? {} : { 'envoy-prefix': envoyPrefix };
354+
const headers =
355+
envoyPrefix == null
356+
? undefined
357+
: // eslint-disable-next-line @typescript-eslint/naming-convention
358+
{ 'envoy-prefix': envoyPrefix };
360359

361-
const client = new dhc.CoreClient(
362-
clientUrl.toString().replace(/\/$/, ''),
363-
{
364-
debug: false, // Set `debug` to true to see debug logs for gRPC transport
365-
headers,
366-
transportFactory: NodeHttp2gRPCTransport.factory,
367-
}
368-
) as CoreUnauthenticatedClient;
360+
const dhc = await this._coreJsApiCache.get(url);
361+
362+
const client = new dhc.CoreClient(urlStr, {
363+
debug: false, // Set `debug` to true to see debug logs for gRPC transport
364+
headers,
365+
transportFactory: NodeHttp2gRPCTransport.factory,
366+
}) as CoreUnauthenticatedClient;
369367

370368
// Attach a dispose method so that client caches can dispose of the client
371369
return Object.assign(client, {

0 commit comments

Comments
 (0)