@@ -229,11 +229,17 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
229
229
protected async startLanguageServer ( fqbn : string , name : string | undefined ) : Promise < void > {
230
230
const release = await this . languageServerStartMutex . acquire ( ) ;
231
231
try {
232
+ await this . hostedPluginSupport . didStart ;
233
+ const details = await this . boardsService . getBoardDetails ( { fqbn } ) ;
234
+ if ( ! details ) {
235
+ // Core is not installed for the selected board.
236
+ console . info ( `Could not start language server for ${ fqbn } . The core is not installed for the board.` ) ;
237
+ return ;
238
+ }
232
239
if ( fqbn === this . languageServerFqbn ) {
233
240
// NOOP
234
241
return ;
235
242
}
236
- await this . hostedPluginSupport . didStart ;
237
243
this . logger . info ( `Starting language server: ${ fqbn } ` ) ;
238
244
const log = this . arduinoPreferences . get ( 'arduino.language.log' ) ;
239
245
let currentSketchPath : string | undefined = undefined ;
@@ -249,16 +255,22 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
249
255
this . fileSystem . fsPath ( new URI ( cliUri ) ) ,
250
256
this . fileSystem . fsPath ( new URI ( lsUri ) ) ,
251
257
] ) ;
252
- this . languageServerFqbn = await this . commandRegistry . executeCommand ( 'arduino.languageserver.start' , {
253
- lsPath,
254
- cliPath,
255
- clangdPath,
256
- log : currentSketchPath ? currentSketchPath : log ,
257
- board : {
258
- fqbn,
259
- name : name ? `"${ name } "` : undefined
260
- }
261
- } ) ;
258
+ this . languageServerFqbn = await Promise . race ( [
259
+ new Promise < undefined > ( ( _ , reject ) => setTimeout ( ( ) => reject ( new Error ( `Timeout after ${ 20_000 } ms.` ) ) , 20_000 ) ) ,
260
+ this . commandRegistry . executeCommand < string > ( 'arduino.languageserver.start' , {
261
+ lsPath,
262
+ cliPath,
263
+ clangdPath,
264
+ log : currentSketchPath ? currentSketchPath : log ,
265
+ board : {
266
+ fqbn,
267
+ name : name ? `"${ name } "` : undefined
268
+ }
269
+ } )
270
+ ] ) ;
271
+ } catch ( e ) {
272
+ console . log ( `Failed to start language server for ${ fqbn } ` , e ) ;
273
+ this . languageServerFqbn = undefined ;
262
274
} finally {
263
275
release ( ) ;
264
276
}
0 commit comments