fix: fix events listener cleanup
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 25 Nov 2023 19:45:28 +0000 (20:45 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 25 Nov 2023 19:45:28 +0000 (20:45 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
CHANGELOG.md
src/pools/abstract-pool.ts
src/pools/cluster/fixed.ts
src/pools/thread/fixed.ts

index c7a27c609541350fca4acea30fec2b78653f8b6d..24762e5f0033f807de9901e216ed73216dd4bd18 100644 (file)
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+### Fixed
+
+- Remove all pool events listener at pool destroying.
+- Remove all worker node events listener at worker node destroying.
+
 ## [3.0.8] - 2023-11-25
 
 ### Fixed
index eb92eb548903a719169f15e658ccbfe86cefe4be..53b7b430efcc626c317e2186e7dbd4b409944dd6 100644 (file)
@@ -989,6 +989,7 @@ export abstract class AbstractPool<
     )
     this.emitter?.emit(PoolEvents.destroy, this.info)
     this.emitter?.emitDestroy()
+    this.emitter?.removeAllListeners()
     this.readyEventEmitted = false
     this.destroying = false
     this.started = false
index 5f067bd7fb4a716f20297f2c907c7632a9607a1b..b74f034bc199d9d4e89f77f0856b00855cf1685a 100644 (file)
@@ -75,6 +75,7 @@ export class FixedClusterPool<
       worker.kill()
     })
     await this.sendKillMessageToWorker(workerNodeKey)
+    workerNode.removeAllListeners()
     worker.disconnect()
     await waitWorkerExit
   }
index ddda04b113ec9028b0cd24c8f53001d12714a901..73740baa92110e213b427fe0ca1f8aeafebe307c 100644 (file)
@@ -70,6 +70,7 @@ export class FixedThreadPool<
     })
     await this.sendKillMessageToWorker(workerNodeKey)
     workerNode.closeChannel()
+    workerNode.removeAllListeners()
     await worker.terminate()
     await waitWorkerExit
   }