From 78f60f82ebd87eb5a12188de3e890435becc8550 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 25 Nov 2023 20:45:28 +0100 Subject: [PATCH] fix: fix events listener cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 5 +++++ src/pools/abstract-pool.ts | 1 + src/pools/cluster/fixed.ts | 1 + src/pools/thread/fixed.ts | 1 + 4 files changed, 8 insertions(+) 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 } -- 2.34.1