Skip to content

Commit 3db0b24

Browse files
authored
Fix the path where we look for LS version for telemetry (#15749)
* Fix the path where we look for LS version for telemetry * Add tracing when version retreival fails
1 parent ff2bc45 commit 3db0b24

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/client/activation/jedi/manager.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import '../../common/extensions';
77
import { inject, injectable, named } from 'inversify';
88

99
import { ICommandManager } from '../../common/application/types';
10-
import { traceDecorators } from '../../common/logger';
10+
import { traceDecorators, traceVerbose } from '../../common/logger';
1111
import { IDisposable, Resource } from '../../common/types';
1212
import { debounceSync } from '../../common/utils/decorators';
1313
import { EXTENSION_ROOT_DIR } from '../../constants';
@@ -80,16 +80,22 @@ export class JediLanguageServerManager implements ILanguageServerManager {
8080
this.interpreter = interpreter;
8181
this.analysisOptions.onDidChange(this.restartLanguageServerDebounced, this, this.disposables);
8282

83-
// Version is actually hardcoded in our requirements.txt.
84-
const requirementsTxt = await fs.readFile(path.join(EXTENSION_ROOT_DIR, 'requirements.txt'), 'utf-8');
85-
86-
// Search using a regex in the text
87-
const match = /jedi-language-server==([0-9\.]*)/.exec(requirementsTxt);
88-
if (match && match.length > 1) {
89-
// eslint-disable-next-line prefer-destructuring
90-
this.lsVersion = match[1];
91-
} else {
92-
this.lsVersion = '0.19.3';
83+
try {
84+
// Version is actually hardcoded in our requirements.txt.
85+
const requirementsTxt = await fs.readFile(
86+
path.join(EXTENSION_ROOT_DIR, 'jedils_requirements.txt'),
87+
'utf-8',
88+
);
89+
90+
// Search using a regex in the text
91+
const match = /jedi-language-server==([0-9\.]*)/.exec(requirementsTxt);
92+
if (match && match.length === 2) {
93+
[, this.lsVersion] = match;
94+
}
95+
} catch (ex) {
96+
// Getting version here is best effort and does not affect how LS works and
97+
// failing to get version should not stop LS from working.
98+
traceVerbose('Failed to get jedi-language-server version: ', ex);
9399
}
94100

95101
await this.analysisOptions.initialize(resource, interpreter);

0 commit comments

Comments
 (0)