mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Do not timeout watch requests (#273)
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
799482b3c4
commit
ac552087d5
@ -102,12 +102,22 @@ export class ContextHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public async getApiTarget() {
|
||||
if (this.apiTarget) { return this.apiTarget }
|
||||
public async getApiTarget(isWatchRequest = false) {
|
||||
if (this.apiTarget && !isWatchRequest) {
|
||||
return this.apiTarget
|
||||
}
|
||||
const timeout = isWatchRequest ? 4 * 60 * 60 * 1000 : 30000 // 4 hours for watch request, 30 seconds for the rest
|
||||
const apiTarget = await this.newApiTarget(timeout)
|
||||
if (!isWatchRequest) {
|
||||
this.apiTarget = apiTarget
|
||||
}
|
||||
return apiTarget
|
||||
}
|
||||
|
||||
this.apiTarget = {
|
||||
protected async newApiTarget(timeout: number) {
|
||||
return {
|
||||
changeOrigin: true,
|
||||
timeout: 30000,
|
||||
timeout: timeout,
|
||||
headers: {
|
||||
"Host": this.clusterUrl.hostname
|
||||
},
|
||||
@ -118,8 +128,6 @@ export class ContextHandler {
|
||||
path: this.clusterUrl.path
|
||||
},
|
||||
}
|
||||
|
||||
return this.apiTarget
|
||||
}
|
||||
|
||||
protected async resolveProxyPort(): Promise<number> {
|
||||
|
||||
@ -130,7 +130,8 @@ export class LensProxy {
|
||||
if (req.url.startsWith("/api-kube/")) {
|
||||
delete req.headers.authorization
|
||||
req.url = req.url.replace("/api-kube", "")
|
||||
return await contextHandler.getApiTarget()
|
||||
const isWatchRequest = req.url.includes("watch=")
|
||||
return await contextHandler.getApiTarget(isWatchRequest)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user