From 940ad2775e98d95d5fcdde88ab01076529b67d7f Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 29 Mar 2022 10:49:12 -0400 Subject: [PATCH] fix type error Signed-off-by: Sebastian Malton --- src/main/lens-proxy.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/lens-proxy.ts b/src/main/lens-proxy.ts index 7f2fbd7281..3fdb437ea5 100644 --- a/src/main/lens-proxy.ts +++ b/src/main/lens-proxy.ts @@ -79,19 +79,18 @@ export class LensProxy extends Singleton { this.proxyServer .on("upgrade", (req: http.IncomingMessage, socket: net.Socket, head: Buffer) => { - const isInternal = req.url.startsWith(`${apiPrefix}?`); const cluster = getClusterForRequest(req); if (!cluster) { logger.error(`[LENS-PROXY]: Could not find cluster for upgrade request from url=${req.url}`); + socket.destroy(); + } else { + const isInternal = req.url.startsWith(`${apiPrefix}?`); + const reqHandler = isInternal ? shellApiRequest : kubeApiUpgradeRequest; - return socket.destroy(); + (async () => reqHandler({ req, socket, head, cluster }))() + .catch(error => logger.error("[LENS-PROXY]: failed to handle proxy upgrade", error)); } - - const reqHandler = isInternal ? shellApiRequest : kubeApiUpgradeRequest; - - (async () => reqHandler({ req, socket, head, cluster }))() - .catch(error => logger.error("[LENS-PROXY]: failed to handle proxy upgrade", error)); }); }