Always end watch stream if connection to kube-api ends (#217)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
Signed-off-by: Cody Belcher <cody.t.belcher@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and Cody Belcher committed 2020-04-16 11:23:41 -05:00
1 parent 8158dcd8a3
commit 7997a236d0
3 files changed
+9 -12

No files matched your search

+1 -1
View File
@@ -156,7 +156,7 @@ export class LensProxy {
if (proxyTarget) {
proxy.web(req, res, proxyTarget)
} else {
await this.router.route(cluster, req, res)
this.router.route(cluster, req, res)
}
})
}
+1 -1
View File
@@ -96,8 +96,8 @@ export class Router {
const type = mimeTypes[path.extname(asset).slice(1)] || "text/plain";
response.setHeader("Content-Type", type);
response.write(data)
response.end()
}
response.end()
})
}
+7 -10
View File
@@ -49,16 +49,13 @@ class ApiWatcher {
}
private doneHandler(error: Error) {
if (error) {
logger.error("watch error: " + error.toString())
this.sendEvent({
type: "STREAM_END",
url: this.apiUrl,
status: 410,
})
return
}
this.start()
if (error) logger.warn("watch ended: " + error.toString())
this.sendEvent({
type: "STREAM_END",
url: this.apiUrl,
status: 410,
})
}
private sendEvent(evt: any) {