From 12f18afe5efd7edcf1ef033cfacedba3aa56c368 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Tue, 9 Jun 2020 09:12:02 +0300 Subject: [PATCH] Return on proxy error if server is already closed Signed-off-by: Lauri Nevala --- src/main/proxy.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/proxy.ts b/src/main/proxy.ts index bcfd432c9d..56febb9273 100644 --- a/src/main/proxy.ts +++ b/src/main/proxy.ts @@ -18,6 +18,7 @@ export class LensProxy { protected retryCounters: Map = new Map() protected router: Router protected proxyServer: http.Server + protected closed = false constructor(port: number, clusterManager: ClusterManager) { this.port = port @@ -34,6 +35,7 @@ export class LensProxy { public close() { logger.info("Closing proxy server") this.proxyServer.close() + this.closed = true } protected buildProxyServer() { @@ -77,6 +79,9 @@ export class LensProxy { } }) proxy.on("error", (error, req, res, target) => { + if(this.closed) { + return + } if (target) { logger.debug("Failed proxy to target: " + JSON.stringify(target)) if (req.method === "GET" && (!res.statusCode || res.statusCode >= 500)) {