From: Jérôme Benoit Date: Tue, 27 Jun 2023 15:54:17 +0000 (+0200) Subject: fix: register message handler on worker only X-Git-Tag: v2.6.6~21 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3749facbef3139d185918f89b1e29c69fc02015f;p=poolifier.git fix: register message handler on worker only Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index dba4ff69..49f72b43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Ensure message handler is only registered in worker. + ## [2.6.5] - 2023-06-27 ### Known issues diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index f42f2c47..25be4820 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -90,8 +90,8 @@ export abstract class AbstractWorker< (this.opts.maxInactiveTime ?? DEFAULT_MAX_INACTIVE_TIME) / 2 ) this.checkAlive.bind(this)() + this.mainWorker?.on('message', this.messageListener.bind(this)) } - this.mainWorker?.on('message', this.messageListener.bind(this)) } private checkWorkerOptions (opts: WorkerOptions): void {