diff --git a/src/main/context-handler.ts b/src/main/context-handler.ts index 52a8e8815e..f3a6d463b7 100644 --- a/src/main/context-handler.ts +++ b/src/main/context-handler.ts @@ -141,7 +141,7 @@ export class ContextHandler { return apiTarget } - protected async newApiTarget(timeout: number) { + protected async newApiTarget(timeout: number): Promise { return { changeOrigin: true, timeout: timeout, diff --git a/src/main/kube-auth-proxy.ts b/src/main/kube-auth-proxy.ts index c6f65f2419..d825918330 100644 --- a/src/main/kube-auth-proxy.ts +++ b/src/main/kube-auth-proxy.ts @@ -28,9 +28,7 @@ export class KubeAuthProxy { public async run(): Promise { if (this.proxyProcess) { - return new Promise((resolve, reject) => { - resolve() - }) + return; } const proxyBin = await this.kubectl.kubectlPath() const configWatcher = watch(this.cluster.kubeconfigPath(), (eventType: string, filename: string) => { diff --git a/src/main/proxy.ts b/src/main/proxy.ts index 13a91ed39a..7f13e80256 100644 --- a/src/main/proxy.ts +++ b/src/main/proxy.ts @@ -98,7 +98,7 @@ export class LensProxy { ws.on("connection", ((con: WebSocket, req: http.IncomingMessage) => { const cluster = this.clusterManager.getClusterForRequest(req) const contextHandler = cluster.contextHandler - const nodeParam = this.getNodeParam(req.url) + const nodeParam = (url.parse(req.url, true).query["node"] || "").toString(); contextHandler.withTemporaryKubeconfig((kubeconfigPath) => { return new Promise(async (resolve, reject) => { @@ -112,18 +112,6 @@ export class LensProxy { return ws } - protected getNodeParam(requestUrl: string) { - const reqUrl = url.parse(requestUrl, true) - const urlParams = reqUrl.query - let nodeParam: string = null - for (const [key, value] of Object.entries(urlParams)) { - if (key === "node") { - nodeParam = value.toString() - } - } - return nodeParam - } - protected async getProxyTarget(req: http.IncomingMessage, contextHandler: ContextHandler): Promise { if (req.url.startsWith("/api-kube/")) { delete req.headers.authorization diff --git a/src/main/shell-session.ts b/src/main/shell-session.ts index 05e49b917f..ed5a42241b 100644 --- a/src/main/shell-session.ts +++ b/src/main/shell-session.ts @@ -131,12 +131,12 @@ export class ShellSession extends EventEmitter { // send shell output to websocket this.shellProcess.onData(((data: string) => { this.sendResponse(data) - }).bind(this)); + })); } protected pipeStdin() { // write websocket messages to shellProcess - this.websocket.on("message", function(data: string) { + this.websocket.on("message", (data: string) => { if (!this.running) { return } const message = Buffer.from(data.slice(1, data.length), "base64").toString() @@ -149,11 +149,10 @@ export class ShellSession extends EventEmitter { this.shellProcess.resize(resizeMsgObj["Width"], resizeMsgObj["Height"]) break; case "9": - this.token = message - this.emit('newToken', this.token) + this.emit('newToken', message) break; } - }.bind(this)) + }) } protected exit(code = 1000) { @@ -162,10 +161,10 @@ export class ShellSession extends EventEmitter { } protected closeWebsocketOnProcessExit() { - this.shellProcess.on("exit", (code) => { + this.shellProcess.onExit(({ exitCode }) => { this.running = false let timeout = 0 - if (code > 0) { + if (exitCode > 0) { this.sendResponse("Terminal will auto-close in 15 seconds ...") timeout = 15*1000 }