aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/installation/download_file.ts2
-rw-r--r--editors/code/src/installation/fetch_latest_artifact_metadata.ts2
-rw-r--r--editors/code/src/installation/language_server.ts27
3 files changed, 26 insertions, 5 deletions
diff --git a/editors/code/src/installation/download_file.ts b/editors/code/src/installation/download_file.ts
index 53bf46d78..b51602ef9 100644
--- a/editors/code/src/installation/download_file.ts
+++ b/editors/code/src/installation/download_file.ts
@@ -20,6 +20,8 @@ export async function downloadFile(
20 20
21 let readBytes = 0; 21 let readBytes = 0;
22 22
23 console.log("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath);
24
23 return new Promise<void>((resolve, reject) => response.body 25 return new Promise<void>((resolve, reject) => response.body
24 .on("data", (chunk: Buffer) => { 26 .on("data", (chunk: Buffer) => {
25 readBytes += chunk.length; 27 readBytes += chunk.length;
diff --git a/editors/code/src/installation/fetch_latest_artifact_metadata.ts b/editors/code/src/installation/fetch_latest_artifact_metadata.ts
index 9141c92ef..7e3700603 100644
--- a/editors/code/src/installation/fetch_latest_artifact_metadata.ts
+++ b/editors/code/src/installation/fetch_latest_artifact_metadata.ts
@@ -19,6 +19,8 @@ export async function fetchLatestArtifactMetadata(
19 19
20 // We skip runtime type checks for simplicity (here we cast from `any` to `GithubRelease`) 20 // We skip runtime type checks for simplicity (here we cast from `any` to `GithubRelease`)
21 21
22 console.log("Issuing request for released artifacts metadata to", requestUrl);
23
22 const response: GithubRelease = await fetch(requestUrl, { 24 const response: GithubRelease = await fetch(requestUrl, {
23 headers: { Accept: "application/vnd.github.v3+json" } 25 headers: { Accept: "application/vnd.github.v3+json" }
24 }) 26 })
diff --git a/editors/code/src/installation/language_server.ts b/editors/code/src/installation/language_server.ts
index c1f37f978..1ce67b8b2 100644
--- a/editors/code/src/installation/language_server.ts
+++ b/editors/code/src/installation/language_server.ts
@@ -2,6 +2,7 @@ import * as vscode from "vscode";
2import * as path from "path"; 2import * as path from "path";
3import { strict as assert } from "assert"; 3import { strict as assert } from "assert";
4import { promises as fs } from "fs"; 4import { promises as fs } from "fs";
5import { promises as dns } from "dns";
5import { spawnSync } from "child_process"; 6import { spawnSync } from "child_process";
6import { throttle } from "throttle-debounce"; 7import { throttle } from "throttle-debounce";
7 8
@@ -25,6 +26,7 @@ export async function downloadLatestLanguageServer(
25 26
26 const installationPath = path.join(installationDir, artifactFileName); 27 const installationPath = path.join(installationDir, artifactFileName);
27 28
29 console.time("Downloading ra_lsp_server");
28 await vscode.window.withProgress( 30 await vscode.window.withProgress(
29 { 31 {
30 location: vscode.ProgressLocation.Notification, 32 location: vscode.ProgressLocation.Notification,
@@ -48,6 +50,7 @@ export async function downloadLatestLanguageServer(
48 ); 50 );
49 } 51 }
50 ); 52 );
53 console.timeEnd("Downloading ra_lsp_server");
51 54
52 await fs.chmod(installationPath, 0o755); // Set (rwx, r_x, r_x) permissions 55 await fs.chmod(installationPath, 0o755); // Set (rwx, r_x, r_x) permissions
53} 56}
@@ -101,15 +104,21 @@ export async function ensureLanguageServerBinary(
101 `Failed to download language server from ${langServerSource.repo.name} ` + 104 `Failed to download language server from ${langServerSource.repo.name} ` +
102 `GitHub repository: ${err.message}` 105 `GitHub repository: ${err.message}`
103 ); 106 );
107
108 await dns.resolve('www.google.com').catch(err => {
109 console.error("DNS resolution failed, there might be an issue with Internet availability");
110 console.error(err);
111 });
112
104 return null; 113 return null;
105 } 114 }
106 115
107 116 if (!isBinaryAvailable(prebuiltBinaryPath)) assert(false,
108 assert( 117 `Downloaded language server binary is not functional.` +
109 isBinaryAvailable(prebuiltBinaryPath), 118 `Downloaded from: ${JSON.stringify(langServerSource)}`
110 "Downloaded language server binary is not functional"
111 ); 119 );
112 120
121
113 vscode.window.showInformationMessage( 122 vscode.window.showInformationMessage(
114 "Rust analyzer language server was successfully installed 🦀" 123 "Rust analyzer language server was successfully installed 🦀"
115 ); 124 );
@@ -119,6 +128,14 @@ export async function ensureLanguageServerBinary(
119 } 128 }
120 129
121 function isBinaryAvailable(binaryPath: string) { 130 function isBinaryAvailable(binaryPath: string) {
122 return spawnSync(binaryPath, ["--version"]).status === 0; 131 const res = spawnSync(binaryPath, ["--version"]);
132
133 // ACHTUNG! `res` type declaration is inherently wrong, see
134 // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/42221
135
136 console.log("Checked binary availablity via --version", res);
137 console.log(binaryPath, "--version output:", res.output?.map(String));
138
139 return res.status === 0;
123 } 140 }
124} 141}