From 132f7d1470444448a6dd46f1d6ffccba1fb3ea26 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 11 Mar 2024 14:13:21 -0800 Subject: [PATCH] Default keepAlive to true for proxy agent --- patches/keepalive.diff | 15 +++++++++++++++ patches/series | 1 + src/node/update.ts | 1 + 3 files changed, 17 insertions(+) create mode 100644 patches/keepalive.diff diff --git a/patches/keepalive.diff b/patches/keepalive.diff new file mode 100644 index 000000000..443fc2f38 --- /dev/null +++ b/patches/keepalive.diff @@ -0,0 +1,15 @@ +This can be removed after upgrading to Node >= 19 as keepAlive is defaulted to +true after 19. + +Index: code-server/lib/vscode/src/vs/platform/request/node/proxy.ts +=================================================================== +--- code-server.orig/lib/vscode/src/vs/platform/request/node/proxy.ts ++++ code-server/lib/vscode/src/vs/platform/request/node/proxy.ts +@@ -42,6 +42,7 @@ export async function getProxyAgent(rawR + port: (proxyEndpoint.port ? +proxyEndpoint.port : 0) || (proxyEndpoint.protocol === 'https' ? 443 : 80), + auth: proxyEndpoint.auth, + rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true, ++ keepAlive: true, + }; + + return requestURL.protocol === 'http:' diff --git a/patches/series b/patches/series index d3370af12..ad79ed9ec 100644 --- a/patches/series +++ b/patches/series @@ -19,3 +19,4 @@ display-language.diff cli-window-open.diff getting-started.diff safari.diff +keepalive.diff diff --git a/src/node/update.ts b/src/node/update.ts index 520c1899e..4e4a1babe 100644 --- a/src/node/update.ts +++ b/src/node/update.ts @@ -105,6 +105,7 @@ export class UpdateProvider { logger.debug("Making request", field("uri", uri)) const isHttps = uri.startsWith("https") const agent = new ProxyAgent({ + keepAlive: true, getProxyForUrl: () => httpProxyUri || "", }) const httpx = isHttps ? https : http