update.ts: Fix response memory leak
This commit is contained in:
parent
67470f0254
commit
cee88ad637
|
@ -106,12 +106,13 @@ export class UpdateProvider {
|
||||||
const httpx = uri.startsWith("https") ? https : http
|
const httpx = uri.startsWith("https") ? https : http
|
||||||
const client = httpx.get(uri, { headers: { "User-Agent": "code-server" } }, (response) => {
|
const client = httpx.get(uri, { headers: { "User-Agent": "code-server" } }, (response) => {
|
||||||
if (!response.statusCode || response.statusCode < 200 || response.statusCode >= 400) {
|
if (!response.statusCode || response.statusCode < 200 || response.statusCode >= 400) {
|
||||||
|
response.destroy()
|
||||||
return reject(new Error(`${uri}: ${response.statusCode || "500"}`))
|
return reject(new Error(`${uri}: ${response.statusCode || "500"}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.statusCode >= 300) {
|
if (response.statusCode >= 300) {
|
||||||
++redirects
|
|
||||||
response.destroy()
|
response.destroy()
|
||||||
|
++redirects
|
||||||
if (redirects > maxRedirects) {
|
if (redirects > maxRedirects) {
|
||||||
return reject(new Error("reached max redirects"))
|
return reject(new Error("reached max redirects"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue