From bc4f7ae28319fdd0f43134a39a9dc57e84f42935 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 5 Aug 2023 12:59:14 +0200 Subject: [PATCH] refactor: add worker id sanity check at message handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/worker/abstract-worker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- 2.34.1