File tree Expand file tree Collapse file tree
apps/api/v2/src/modules/slots/slots-2024-04-15/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export class SlotsWorkerService_2024_04_15 implements OnModuleDestroy {
3232 private readonly logger = new Logger ( "SlotsWorkerService_2024_04_15" ) ;
3333 private readonly workerPool : Worker [ ] = [ ] ;
3434 private readonly maxWorkers : number ;
35+ private handledWorkers = new Set < number > ( ) ;
3536 private readonly taskQueue : Array < {
3637 resolve : ( value : TimeSlots ) => void ;
3738 reject : ( reason : Error ) => void ;
@@ -93,8 +94,13 @@ export class SlotsWorkerService_2024_04_15 implements OnModuleDestroy {
9394 */
9495 private handleWorkerFailure ( failedWorker : Worker ) : void {
9596 // Remove the failed worker from both pools
96- this . logger . error ( `Handling Worker ${ failedWorker . threadId } failure` ) ;
97- this . workerPool . splice ( this . workerPool . indexOf ( failedWorker ) , 1 ) ;
97+ if ( this . handledWorkers . has ( failedWorker . threadId ) ) return ;
98+ this . handledWorkers . add ( failedWorker . threadId )
99+ const workerIndex = this . workerPool . indexOf ( failedWorker ) ;
100+ if ( workerIndex !== - 1 ) {
101+ this . workerPool . splice ( workerIndex , 1 ) ;
102+ }
103+
98104 this . availableWorkers = this . availableWorkers . filter ( ( w ) => w !== failedWorker ) ;
99105
100106 try {
You can’t perform that action at this time.
0 commit comments