aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package-lock.json5
-rw-r--r--editors/code/package.json1
-rw-r--r--editors/code/src/installation/download_file.ts7
3 files changed, 3 insertions, 10 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json
index e737d6ace..5c056463e 100644
--- a/editors/code/package-lock.json
+++ b/editors/code/package-lock.json
@@ -753,11 +753,6 @@
753 "os-tmpdir": "~1.0.1" 753 "os-tmpdir": "~1.0.1"
754 } 754 }
755 }, 755 },
756 "ts-nested-error": {
757 "version": "1.1.3",
758 "resolved": "https://registry.npmjs.org/ts-nested-error/-/ts-nested-error-1.1.3.tgz",
759 "integrity": "sha512-CJSRAhXr6phdkuu65U/ctkY/TBzjkg2g1sL9juSG/PP3ONQNCbeksMy54OfCBTUt13hSpHNbnTO1OBPunOHj/Q=="
760 },
761 "tslib": { 756 "tslib": {
762 "version": "1.10.0", 757 "version": "1.10.0",
763 "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", 758 "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
diff --git a/editors/code/package.json b/editors/code/package.json
index ce7117c69..f687eb8d4 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -27,7 +27,6 @@
27 "jsonc-parser": "^2.1.0", 27 "jsonc-parser": "^2.1.0",
28 "node-fetch": "^2.6.0", 28 "node-fetch": "^2.6.0",
29 "throttle-debounce": "^2.1.0", 29 "throttle-debounce": "^2.1.0",
30 "ts-nested-error": "^1.1.3",
31 "vscode-languageclient": "^6.1.0" 30 "vscode-languageclient": "^6.1.0"
32 }, 31 },
33 "devDependencies": { 32 "devDependencies": {
diff --git a/editors/code/src/installation/download_file.ts b/editors/code/src/installation/download_file.ts
index 591de0d31..d154f4816 100644
--- a/editors/code/src/installation/download_file.ts
+++ b/editors/code/src/installation/download_file.ts
@@ -3,7 +3,6 @@ import * as fs from "fs";
3import * as stream from "stream"; 3import * as stream from "stream";
4import * as util from "util"; 4import * as util from "util";
5import { strict as assert } from "assert"; 5import { strict as assert } from "assert";
6import { NestedError } from "ts-nested-error";
7 6
8const pipeline = util.promisify(stream.pipeline); 7const pipeline = util.promisify(stream.pipeline);
9 8
@@ -19,13 +18,13 @@ export async function downloadFile(
19 destFilePermissions: number, 18 destFilePermissions: number,
20 onProgress: (readBytes: number, totalBytes: number) => void 19 onProgress: (readBytes: number, totalBytes: number) => void
21): Promise<void> { 20): Promise<void> {
22 const res = await fetch(url).catch(NestedError.rethrow("Failed at initial fetch")); 21 const res = await fetch(url);
23 22
24 if (!res.ok) { 23 if (!res.ok) {
25 console.log("Error", res.status, "while downloading file from", url); 24 console.log("Error", res.status, "while downloading file from", url);
26 console.dir({ body: await res.text(), headers: res.headers }, { depth: 3 }); 25 console.dir({ body: await res.text(), headers: res.headers }, { depth: 3 });
27 26
28 throw new NestedError(`Got response ${res.status}`); 27 throw new Error(`Got response ${res.status} when trying to download a file.`);
29 } 28 }
30 29
31 const totalBytes = Number(res.headers.get('content-length')); 30 const totalBytes = Number(res.headers.get('content-length'));
@@ -41,7 +40,7 @@ export async function downloadFile(
41 40
42 const destFileStream = fs.createWriteStream(destFilePath, { mode: destFilePermissions }); 41 const destFileStream = fs.createWriteStream(destFilePath, { mode: destFilePermissions });
43 42
44 await pipeline(res.body, destFileStream).catch(NestedError.rethrow("Piping file error")); 43 await pipeline(res.body, destFileStream);
45 return new Promise<void>(resolve => { 44 return new Promise<void>(resolve => {
46 destFileStream.on("close", resolve); 45 destFileStream.on("close", resolve);
47 destFileStream.destroy(); 46 destFileStream.destroy();