Skip to content

Try to trigger intermittent failure #1597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/sourcekit-lsp/LanguageClientManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,21 @@ export class LanguageClientManager implements vscode.Disposable {
}

private async startClient(client: LanguageClient, errorHandler: SourceKitLSPErrorHandler) {
client.onDidChangeState(e => {
// if state is now running add in any sub-folder workspaces that
// we have cached. If this is the first time we are starting then
// we won't have any sub folder workspaces, but if the server crashed
// or we forced a restart then we need to do this
if (e.oldState === State.Starting && e.newState === State.Running) {
void this.addSubFolderWorkspaces(client);
}
const runningPromise = new Promise<void>((res, rej) => {
const disposable = client.onDidChangeState(e => {
// if state is now running add in any sub-folder workspaces that
// we have cached. If this is the first time we are starting then
// we won't have any sub folder workspaces, but if the server crashed
// or we forced a restart then we need to do this
if (e.oldState === State.Starting && e.newState === State.Running) {
res();
disposable.dispose();
void this.addSubFolderWorkspaces(client);
} else if (e.oldState === State.Starting && e.newState === State.Stopped) {
rej("SourceKit-LSP failed to start");
disposable.dispose();
}
});
});
if (client.clientOptions.workspaceFolder) {
this.folderContext.workspaceContext.outputChannel.log(
Expand All @@ -465,6 +472,7 @@ export class LanguageClientManager implements vscode.Disposable {
// start client
this.clientReadyPromise = client
.start()
.then(() => runningPromise)
.then(() => {
// Now that we've started up correctly, start the error handler to auto-restart
// if sourcekit-lsp crashes during normal operation.
Expand Down