From bd808cdb55696b34545a3781faa18f3855fc19eb Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 30 Oct 2024 14:53:00 +0100 Subject: [PATCH] apply learnings from wsl download fix --- src/server/download.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/download.ts b/src/server/download.ts index 31c50ea..dbf3b40 100644 --- a/src/server/download.ts +++ b/src/server/download.ts @@ -26,14 +26,13 @@ async function getLatestBuild(quality: 'stable' | 'insider'): Promise { return new Promise((resolve, reject) => { const url = `https://update.code.visualstudio.com/commit:${commit}/web-standalone/${quality}`; - const httpLibrary = url.startsWith('https') ? https : http; - httpLibrary.get(url, { method: 'HEAD', ...getAgent(url) }, res => { - console.log(res.statusCode, res.headers.location); + https.get(url, { method: 'HEAD', ...getAgent(url) }, res => { if ((res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307) && res.headers.location) { resolve(res.headers.location); } else { resolve(undefined); } + res.resume(); // Discard response body }); }); } @@ -68,6 +67,7 @@ async function downloadAndUntar(downloadUrl: string, destination: string, messag received += chunk.length; }); + res.on('error', reject); res.on('end', () => { if (timeout) { clearTimeout(timeout);