@@ -2,6 +2,7 @@ import * as vscode from "vscode";
2
2
import * as path from "path" ;
3
3
import { strict as assert } from "assert" ;
4
4
import { promises as fs } from "fs" ;
5
+ import { promises as dns } from "dns" ;
5
6
import { spawnSync } from "child_process" ;
6
7
import { throttle } from "throttle-debounce" ;
7
8
@@ -25,6 +26,7 @@ export async function downloadLatestLanguageServer(
25
26
26
27
const installationPath = path . join ( installationDir , artifactFileName ) ;
27
28
29
+ console . time ( "Downloading ra_lsp_server" ) ;
28
30
await vscode . window . withProgress (
29
31
{
30
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
55
await fs . chmod ( installationPath , 0o755 ) ; // Set (rwx, r_x, r_x) permissions
53
56
}
@@ -101,15 +104,21 @@ export async function ensureLanguageServerBinary(
101
104
`Failed to download language server from ${ langServerSource . repo . name } ` +
102
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
113
return null ;
105
114
}
106
115
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 ) } `
111
119
) ;
112
120
121
+
113
122
vscode . window . showInformationMessage (
114
123
"Rust analyzer language server was successfully installed 🦀"
115
124
) ;
@@ -119,6 +128,14 @@ export async function ensureLanguageServerBinary(
119
128
}
120
129
121
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
}
0 commit comments