@@ -24,7 +24,6 @@ export class RconService {
2424
2525 private connections : Record < string , RconClient > = { } ;
2626 private connectTimeouts : Record < string , NodeJS . Timeout > = { } ;
27- private activeOperations = new Set < string > ( ) ;
2827
2928 public async connect ( serverId : string ) : Promise < RconClient | null > {
3029 if ( this . connections [ serverId ] ) {
@@ -179,9 +178,6 @@ export class RconService {
179178
180179 private setupConnectionTimeout ( serverId : string ) {
181180 clearTimeout ( this . connectTimeouts [ serverId ] ) ;
182- if ( this . activeOperations . has ( serverId ) ) {
183- return ;
184- }
185181 this . connectTimeouts [ serverId ] = setTimeout ( async ( ) => {
186182 await this . disconnect ( serverId ) ;
187183 } , this . CONNECTION_TIMEOUT ) ;
@@ -258,13 +254,13 @@ export class RconService {
258254
259255 this . logger . log ( `generating cvars for build: ${ buildId } ` ) ;
260256
257+ let rcon : RconClient | null = null ;
261258 try {
262- const rcon = await this . connect ( serverId ) ;
259+ rcon = await this . connect ( serverId ) ;
263260 if ( ! rcon ) {
264261 throw Error ( `unable to connect to server ${ serverId } ` ) ;
265262 }
266263
267- this . activeOperations . add ( serverId ) ;
268264 clearTimeout ( this . connectTimeouts [ serverId ] ) ;
269265 delete this . connectTimeouts [ serverId ] ;
270266
@@ -282,16 +278,19 @@ export class RconService {
282278 description : string ;
283279 } > = [ ] ;
284280
285- try {
286- for ( const prefix of prefixes ) {
281+ for ( const prefix of prefixes ) {
282+ try {
287283 const parsedCvars = this . parseCvarList (
288284 await rcon . send ( `Cvarlist ${ prefix } ` ) ,
289285 ) ;
290286 allCvars . push ( ...parsedCvars ) ;
287+ } catch ( error ) {
288+ this . logger . error (
289+ `unable to generate cvars for build: ${ buildId } on prefix ${ prefix } ` ,
290+ error ,
291+ ) ;
292+ throw error ;
291293 }
292- } finally {
293- this . activeOperations . delete ( serverId ) ;
294- this . setupConnectionTimeout ( serverId ) ;
295294 }
296295
297296 await this . typeSenseService . resetCvars ( ) ;
@@ -318,6 +317,7 @@ export class RconService {
318317 ) ;
319318 await this . cache . put ( failureCacheKey , true , 600 ) ;
320319 } finally {
320+ await this . disconnect ( serverId ) ;
321321 await this . releaseCvarsLock ( buildId ) ;
322322 }
323323 }
0 commit comments