diff --git a/src/common/k8s-api/json-api.ts b/src/common/k8s-api/json-api.ts index bb7a1f7705..5d207e13a4 100644 --- a/src/common/k8s-api/json-api.ts +++ b/src/common/k8s-api/json-api.ts @@ -56,6 +56,10 @@ export interface JsonApiConfig { debug?: boolean; getRequestOptions?: () => Promise; } + +const httpAgent = new HttpAgent({ keepAlive: true }); +const httpsAgent = new HttpsAgent({ keepAlive: true }); + export class JsonApi { static reqInitDefault: RequestInit = { headers: { @@ -98,9 +102,7 @@ export class JsonApi { } if (!reqInit.agent) { - const agentOpts = { keepAlive: true }; - - reqInit.agent = reqUrl.startsWith("https:") ? new HttpsAgent(agentOpts) : new HttpAgent(agentOpts); + reqInit.agent = reqUrl.startsWith("https:") ? httpsAgent : httpAgent; } if (query) {