From: Jérôme Benoit Date: Sat, 5 Aug 2023 10:59:14 +0000 (+0200) Subject: refactor: add worker id sanity check at message handling X-Git-Tag: v2.6.22~16 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bc4f7ae28319fdd0f43134a39a9dc57e84f42935;p=poolifier.git refactor: add worker id sanity check at message handling Signed-off-by: Jérôme Benoit --- diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index b9e3deb0..64627efb 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -293,7 +293,9 @@ export abstract class AbstractWorker< * @param message - The received message. */ protected messageListener (message: MessageValue): void { - if (message.workerId === this.id) { + if (message.workerId != null && message.workerId !== this.id) { + throw new Error('Message worker id does not match worker id') + } else if (message.workerId === this.id) { if (message.statistics != null) { // Statistics message received this.statistics = message.statistics