fix: guard worker node back pressure flag change
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 8 May 2024 21:36:23 +0000 (23:36 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 8 May 2024 21:36:23 +0000 (23:36 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/worker-node.ts

index 88c6e8d18bceea402f24d5b88bf5aa9ce4db0b78..c1c1e0a99b2bc3200e58e85d7c8d1b29aacaa893 100644 (file)
@@ -90,8 +90,8 @@ export class WorkerNode<Worker extends IWorker, Data = unknown>
       this.setBackPressureFlag = true
       this.info.backPressure = true
       this.emit('backPressure', { workerId: this.info.id })
+      this.setBackPressureFlag = false
     }
-    this.setBackPressureFlag = false
     return tasksQueueSize
   }
 
@@ -105,8 +105,8 @@ export class WorkerNode<Worker extends IWorker, Data = unknown>
     ) {
       this.setBackPressureFlag = true
       this.info.backPressure = false
+      this.setBackPressureFlag = false
     }
-    this.setBackPressureFlag = false
     return task
   }