fix: register message handler on worker only
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 27 Jun 2023 15:54:17 +0000 (17:54 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 27 Jun 2023 15:54:17 +0000 (17:54 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
CHANGELOG.md
src/worker/abstract-worker.ts

index dba4ff69dc8d702b2a0ea88d22abf184d2258e5a..49f72b434bd0ac4dd6efb51cb7e9e5d917e4b4f7 100644 (file)
@@ -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
index f42f2c473aaaf78e926e029b22b67d82c11b8d54..25be4820a0e8c59faa8917e0a809633c0d97de83 100644 (file)
@@ -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 {