@@ -9,7 +9,7 @@ import * as manifest from '../manifest';
99import { ChildProcess , spawn } from 'node:child_process' ;
1010import { MessageConnection } from 'vscode-jsonrpc' ;
1111import { createMessageConnection , StreamMessageReader , StreamMessageWriter } from 'vscode-jsonrpc/node' ;
12- import { RpcMethods , RpcInterface } from './interface/rpc-interface' ;
12+ import { RpcMethods , RpcInterface , GetVersionResult } from './interface/rpc-interface' ;
1313import { constructor } from '../generic/constructor' ;
1414import { Optional } from '../generic/type-helper' ;
1515import { debounce } from 'lodash' ;
@@ -43,7 +43,7 @@ class CsolutionServiceImpl extends RpcMethods implements CsolutionService {
4343 private readonly debouncedLoadPacks = debounce ( super . loadPacks . bind ( this ) , 1000 ) ;
4444 private csolutionBin = 'csolution' ;
4545 private exitPromise : Promise < void > | undefined ;
46- private hasReportedVersionForSession = false ;
46+ private cachedVersion : GetVersionResult = { success : false } ;
4747 private readonly mutex : Mutex ;
4848
4949 constructor (
@@ -72,22 +72,21 @@ class CsolutionServiceImpl extends RpcMethods implements CsolutionService {
7272 return ( response ?? { } ) as TResponse ;
7373 }
7474
75+ public async getVersion ( ) : Promise < GetVersionResult > {
76+ if ( ! this . cachedVersion . success ) {
77+ // Query daemon version once per launched session
78+ this . cachedVersion = await super . getVersion ( ) ;
79+ console . log ( 'csolution version:' , this . cachedVersion ) ;
80+ }
81+ return this . cachedVersion ;
82+ }
83+
7584 public async loadPacks ( ) {
7685 if ( this . idxWatcher === undefined ) {
7786 this . watchPackIdxFile ( ) ;
7887 }
79-
80- // Query daemon version once per launched session right before first LoadPacks.
81- if ( ! this . hasReportedVersionForSession ) {
82- try {
83- const version = await super . getVersion ( ) ;
84- console . log ( 'csolution version:' , version ) ;
85- } catch ( error ) {
86- console . warn ( 'Unable to query csolution version before loadPacks:' , error ) ;
87- } finally {
88- this . hasReportedVersionForSession = true ;
89- }
90- }
88+ // ensure version is cached
89+ await this . getVersion ( ) ;
9190
9291 return super . loadPacks ( ) ;
9392 }
@@ -145,7 +144,7 @@ class CsolutionServiceImpl extends RpcMethods implements CsolutionService {
145144 this . idxWatcher = undefined ;
146145 this . connection ?. dispose ( ) ;
147146 this . connection = undefined ;
148- this . hasReportedVersionForSession = false ;
147+ this . cachedVersion = { success : false } ;
149148 }
150149
151150 private async launch ( ) : Promise < boolean > {
0 commit comments