Skip to content

Commit 7cba77e

Browse files
author
Veetaha
committed
vscode: added logging when donloading binaries
1 parent f3240e2 commit 7cba77e

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

editors/code/src/installation/download_file.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export async function downloadFile(
2020

2121
let readBytes = 0;
2222

23+
console.log("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath);
24+
2325
return new Promise<void>((resolve, reject) => response.body
2426
.on("data", (chunk: Buffer) => {
2527
readBytes += chunk.length;

editors/code/src/installation/fetch_latest_artifact_metadata.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export async function fetchLatestArtifactMetadata(
1919

2020
// We skip runtime type checks for simplicity (here we cast from `any` to `GithubRelease`)
2121

22+
console.log("Issuing request for released artifacts metadata to", requestUrl);
23+
2224
const response: GithubRelease = await fetch(requestUrl, {
2325
headers: { Accept: "application/vnd.github.v3+json" }
2426
})

editors/code/src/installation/language_server.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from "vscode";
22
import * as path from "path";
33
import { strict as assert } from "assert";
44
import { promises as fs } from "fs";
5+
import { promises as dns } from "dns";
56
import { spawnSync } from "child_process";
67
import { throttle } from "throttle-debounce";
78

@@ -25,6 +26,7 @@ export async function downloadLatestLanguageServer(
2526

2627
const installationPath = path.join(installationDir, artifactFileName);
2728

29+
console.time("Downloading ra_lsp_server");
2830
await vscode.window.withProgress(
2931
{
3032
location: vscode.ProgressLocation.Notification,
@@ -48,6 +50,7 @@ export async function downloadLatestLanguageServer(
4850
);
4951
}
5052
);
53+
console.timeEnd("Downloading ra_lsp_server");
5154

5255
await fs.chmod(installationPath, 0o755); // Set (rwx, r_x, r_x) permissions
5356
}
@@ -101,15 +104,21 @@ export async function ensureLanguageServerBinary(
101104
`Failed to download language server from ${langServerSource.repo.name} ` +
102105
`GitHub repository: ${err.message}`
103106
);
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+
104113
return null;
105114
}
106115

107-
108-
assert(
109-
isBinaryAvailable(prebuiltBinaryPath),
110-
"Downloaded language server binary is not functional"
116+
if (!isBinaryAvailable(prebuiltBinaryPath)) assert(false,
117+
`Downloaded language server binary is not functional.` +
118+
`Downloaded from: ${JSON.stringify(langServerSource)}`
111119
);
112120

121+
113122
vscode.window.showInformationMessage(
114123
"Rust analyzer language server was successfully installed 🦀"
115124
);
@@ -119,6 +128,14 @@ export async function ensureLanguageServerBinary(
119128
}
120129

121130
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;
123140
}
124141
}

0 commit comments

Comments
 (0)