From: Jérôme Benoit Date: Sat, 25 Nov 2023 19:45:28 +0000 (+0100) Subject: fix: fix events listener cleanup X-Git-Tag: v3.0.9~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=78f60f82ebd87eb5a12188de3e890435becc8550;p=poolifier.git fix: fix events listener cleanup Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index c7a27c60..24762e5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index eb92eb54..53b7b430 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -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 diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index 5f067bd7..b74f034b 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -75,6 +75,7 @@ export class FixedClusterPool< worker.kill() }) await this.sendKillMessageToWorker(workerNodeKey) + workerNode.removeAllListeners() worker.disconnect() await waitWorkerExit } diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index ddda04b1..73740baa 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -70,6 +70,7 @@ export class FixedThreadPool< }) await this.sendKillMessageToWorker(workerNodeKey) workerNode.closeChannel() + workerNode.removeAllListeners() await worker.terminate() await waitWorkerExit }