refactor: cleanup message passing code
[poolifier.git] / src / pools / abstract-pool.ts
index 06e69a6e3140da3092e75a6ff7040e201c70255c..18d4fb8362dcfdd9de125e0e83ca51aa91b98ff3 100644 (file)
@@ -510,7 +510,9 @@ export abstract class AbstractPool<
    * @throws {@link https://nodejs.org/api/errors.html#class-error} If the worker id is invalid.
    */
   private checkMessageWorkerId (message: MessageValue<Response>): void {
-    if (
+    if (message.workerId == null) {
+      throw new Error('Worker message received without worker id')
+    } else if (
       message.workerId != null &&
       this.getWorkerNodeKeyByWorkerId(message.workerId) === -1
     ) {