update.ts: Fix response memory leak

This commit is contained in:
Anmol Sethi 2020-12-04 00:02:00 -05:00
parent 67470f0254
commit cee88ad637
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB
1 changed files with 2 additions and 1 deletions

View File

@ -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"))
}