Catch ipc errors on proxy exit

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala committed 2020-04-03 17:45:35 +03:00
1 parent 7450557f17
commit 73d6307e6d
1 file changed
+3 -4
+3 -4
View File
@@ -59,7 +59,7 @@ export class KubeAuthProxy {
}) })
this.proxyProcess.on("exit", (code) => { this.proxyProcess.on("exit", (code) => {
logger.error(`proxy ${this.cluster.contextName} exited with code ${code}`) logger.error(`proxy ${this.cluster.contextName} exited with code ${code}`)
this.sendIpcLogMessage( `proxy exited with code ${code}`, "stderr") this.sendIpcLogMessage( `proxy exited with code ${code}`, "stderr").catch((_) => {})
this.proxyProcess = null this.proxyProcess = null
configWatcher.close() configWatcher.close()
}) })
@@ -95,15 +95,14 @@ export class KubeAuthProxy {
return errorMsg return errorMsg
} }
protected sendIpcLogMessage(data: string, stream: string) { protected async sendIpcLogMessage(data: string, stream: string) {
this.promiseIpc.send(`kube-auth:${this.cluster.id}`, findMainWebContents(), { data: data, stream: stream }) await this.promiseIpc.send(`kube-auth:${this.cluster.id}`, findMainWebContents(), { data: data, stream: stream })
} }
public exit() { public exit() {
if (this.proxyProcess) { if (this.proxyProcess) {
logger.debug(`Stopping local proxy: ${this.cluster.contextName}`) logger.debug(`Stopping local proxy: ${this.cluster.contextName}`)
this.proxyProcess.kill() this.proxyProcess.kill()
this.proxyProcess = null
} }
} }
} }