Skip to content

Commit

Permalink
Fix clash in language server session ids
Browse files Browse the repository at this point in the history
Fixes an issue where language server sessions ids clashed when starting multiple language servers.
The issue was encourented when attempting to start the `cpp` language server which could not properly
find the `cpp.clangdExecutable` since the `startParameters` were overwritten.

**Example**:
The issue can be seen in the following example. Let's assume there are two language servers, A and B.
Language server A creates it's session id as 1, then B creates it's session id as 1 which essentially
overwrites the previous session information. When it comes time to configurate the language server
and start it with its `startParams` we query the sessions to get the values. In this case, the proper
values of A have already been overwritten and we can no longer properly start the LS.

In the example of `cpp`, we attempt to tell the language server where `clangd` is located, but since
we also have TypeScript who registers a session, the values for `cpp` have been overwritten and we
can no longer start the LS.

Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Feb 15, 2019
1 parent 1730624 commit 4b0b09d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/languages/src/node/languages-backend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export class LanguagesBackendContribution implements MessagingService.Contributi
@inject(ContributionProvider) @named(LanguageServerContribution)
protected readonly contributors: ContributionProvider<LanguageServerContribution>;

protected readonly ids = new Map<string, number>();
protected nextId: number = 1;
protected readonly sessions = new Map<string, any>();

async create(contributionId: string, startParameters: any): Promise<string> {
const id = (this.ids.get(contributionId) || 0) + 1;
this.ids.set(contributionId, id);
const id = this.nextId;
this.nextId++;
const sessionId = String(id);
this.sessions.set(sessionId, startParameters);
return sessionId;
Expand Down

0 comments on commit 4b0b09d

Please sign in to comment.