From cee88ad6372d419f533d52513b5d4d161c1156b2 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 4 Dec 2020 00:02:00 -0500 Subject: [PATCH] update.ts: Fix response memory leak --- src/node/update.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/update.ts b/src/node/update.ts index a156aad6..6f9aa39e 100644 --- a/src/node/update.ts +++ b/src/node/update.ts @@ -106,12 +106,13 @@ export class UpdateProvider { const httpx = uri.startsWith("https") ? https : http const client = httpx.get(uri, { headers: { "User-Agent": "code-server" } }, (response) => { if (!response.statusCode || response.statusCode < 200 || response.statusCode >= 400) { + response.destroy() return reject(new Error(`${uri}: ${response.statusCode || "500"}`)) } if (response.statusCode >= 300) { - ++redirects response.destroy() + ++redirects if (redirects > maxRedirects) { return reject(new Error("reached max redirects")) }