diff --git a/editors/code/src/installation/download_file.ts b/editors/code/src/installation/download_file.ts index 53bf46d789..b51602ef9f 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((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 9141c92efe..7e37006031 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 c1f37f9786..1ce67b8b25 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; } }