about summary refs log tree commit diff
path: root/editors/code
diff options
context:
space:
mode:
authorVeetaha <gerzoh1@gmail.com>2020-02-09 15:01:00 +0200
committerVeetaha <gerzoh1@gmail.com>2020-02-09 15:01:00 +0200
commit7cba77ed4e4207b2e24b8dd57723368c2717bb2a (patch)
tree7f61ae16e22607d28b916345e8a87533ed2b467d /editors/code
parentf3240e22c6de69b408a83b59e85f40fb913acfab (diff)
downloadrust-7cba77ed4e4207b2e24b8dd57723368c2717bb2a.tar.gz
rust-7cba77ed4e4207b2e24b8dd57723368c2717bb2a.zip
vscode: added logging when donloading binaries
Diffstat (limited to 'editors/code')
-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 53bf46d7893..b51602ef9fc 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(
 
     let readBytes = 0;
 
+    console.log("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath);
+
     return new Promise<void>((resolve, reject) => response.body
         .on("data", (chunk: Buffer) => {
             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 9141c92efe1..7e370060313 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(
 
     // We skip runtime type checks for simplicity (here we cast from `any` to `GithubRelease`)
 
+    console.log("Issuing request for released artifacts metadata to", requestUrl);
+
     const response: GithubRelease = await fetch(requestUrl, {
             headers: { Accept: "application/vnd.github.v3+json" }
         })
diff --git a/editors/code/src/installation/language_server.ts b/editors/code/src/installation/language_server.ts
index c1f37f97863..1ce67b8b25b 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";
 import * as path from "path";
 import { strict as assert } from "assert";
 import { promises as fs } from "fs";
+import { promises as dns } from "dns";
 import { spawnSync } from "child_process";
 import { throttle } from "throttle-debounce";
 
@@ -25,6 +26,7 @@ export async function downloadLatestLanguageServer(
 
     const installationPath = path.join(installationDir, artifactFileName);
 
+    console.time("Downloading ra_lsp_server");
     await vscode.window.withProgress(
         {
             location: vscode.ProgressLocation.Notification,
@@ -48,6 +50,7 @@ export async function downloadLatestLanguageServer(
             );
         }
     );
+    console.timeEnd("Downloading ra_lsp_server");
 
     await fs.chmod(installationPath, 0o755); // Set (rwx, r_x, r_x) permissions
 }
@@ -101,15 +104,21 @@ export async function ensureLanguageServerBinary(
                     `Failed to download language server from ${langServerSource.repo.name} ` +
                     `GitHub repository: ${err.message}`
                 );
+
+                await dns.resolve('www.google.com').catch(err => {
+                    console.error("DNS resolution failed, there might be an issue with Internet availability");
+                    console.error(err);
+                });
+
                 return null;
             }
 
-
-            assert(
-                isBinaryAvailable(prebuiltBinaryPath),
-                "Downloaded language server binary is not functional"
+            if (!isBinaryAvailable(prebuiltBinaryPath)) assert(false,
+                `Downloaded language server binary is not functional.` +
+                `Downloaded from: ${JSON.stringify(langServerSource)}`
             );
 
+
             vscode.window.showInformationMessage(
                 "Rust analyzer language server was successfully installed 🦀"
             );
@@ -119,6 +128,14 @@ export async function ensureLanguageServerBinary(
     }
 
     function isBinaryAvailable(binaryPath: string) {
-        return spawnSync(binaryPath, ["--version"]).status === 0;
+        const res = spawnSync(binaryPath, ["--version"]);
+
+        // ACHTUNG! `res` type declaration is inherently wrong, see
+        // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/42221
+
+        console.log("Checked binary availablity via --version", res);
+        console.log(binaryPath, "--version output:", res.output?.map(String));
+
+        return res.status === 0;
     }
 }