mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-10 22:26:32 +00:00
Do not start LS if core for board is missing.
- Added a 20 sec timeout to the LS process start. - Discard running LS FQBN when the LS start has failed. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
596d54a102
commit
cdadda85e5
@ -229,11 +229,17 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
|||||||
protected async startLanguageServer(fqbn: string, name: string | undefined): Promise<void> {
|
protected async startLanguageServer(fqbn: string, name: string | undefined): Promise<void> {
|
||||||
const release = await this.languageServerStartMutex.acquire();
|
const release = await this.languageServerStartMutex.acquire();
|
||||||
try {
|
try {
|
||||||
|
await this.hostedPluginSupport.didStart;
|
||||||
|
const details = await this.boardsService.getBoardDetails({ fqbn });
|
||||||
|
if (!details) {
|
||||||
|
// Core is not installed for the selected board.
|
||||||
|
console.info(`Could not start language server for ${fqbn}. The core is not installed for the board.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (fqbn === this.languageServerFqbn) {
|
if (fqbn === this.languageServerFqbn) {
|
||||||
// NOOP
|
// NOOP
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.hostedPluginSupport.didStart;
|
|
||||||
this.logger.info(`Starting language server: ${fqbn}`);
|
this.logger.info(`Starting language server: ${fqbn}`);
|
||||||
const log = this.arduinoPreferences.get('arduino.language.log');
|
const log = this.arduinoPreferences.get('arduino.language.log');
|
||||||
let currentSketchPath: string | undefined = undefined;
|
let currentSketchPath: string | undefined = undefined;
|
||||||
@ -249,7 +255,9 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
|||||||
this.fileSystem.fsPath(new URI(cliUri)),
|
this.fileSystem.fsPath(new URI(cliUri)),
|
||||||
this.fileSystem.fsPath(new URI(lsUri)),
|
this.fileSystem.fsPath(new URI(lsUri)),
|
||||||
]);
|
]);
|
||||||
this.languageServerFqbn = await this.commandRegistry.executeCommand('arduino.languageserver.start', {
|
this.languageServerFqbn = await Promise.race([
|
||||||
|
new Promise<undefined>((_, reject) => setTimeout(() => reject(new Error(`Timeout after ${20_000} ms.`)), 20_000)),
|
||||||
|
this.commandRegistry.executeCommand<string>('arduino.languageserver.start', {
|
||||||
lsPath,
|
lsPath,
|
||||||
cliPath,
|
cliPath,
|
||||||
clangdPath,
|
clangdPath,
|
||||||
@ -258,7 +266,11 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
|||||||
fqbn,
|
fqbn,
|
||||||
name: name ? `"${name}"` : undefined
|
name: name ? `"${name}"` : undefined
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
]);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(`Failed to start language server for ${fqbn}`, e);
|
||||||
|
this.languageServerFqbn = undefined;
|
||||||
} finally {
|
} finally {
|
||||||
release();
|
release();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user