X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fabstract-worker.ts;h=64627efb8823198c6cb09c81fbdded3bef046f01;hb=637100d9f7507bb89a42120c7dec2f0db688b1a5;hp=1b34fb139dd7d0d6513a298be184c5c342d8bcef;hpb=82ea6492d3318a170559bb57501dc16023bb18d8;p=poolifier.git diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 1b34fb13..64627efb 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -243,7 +243,7 @@ export abstract class AbstractWorker< * @returns The names of the worker's task functions. */ public listTaskFunctions (): string[] { - return Array.from(this.taskFunctions.keys()) + return [...this.taskFunctions.keys()] } /** @@ -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 @@ -302,7 +304,7 @@ export abstract class AbstractWorker< !this.isMain && message.checkActive ? this.startCheckActive() : this.stopCheckActive() - } else if (message.id != null && message.data != null) { + } else if (message.taskId != null && message.data != null) { // Task message received this.run(message) } else if (message.kill === true) { @@ -422,7 +424,7 @@ export abstract class AbstractWorker< data: res, taskPerformance, workerId: this.id, - id: task.id + taskId: task.taskId }) } catch (e) { const errorMessage = this.handleError(e as Error | string) @@ -433,7 +435,7 @@ export abstract class AbstractWorker< data: task.data }, workerId: this.id, - id: task.id + taskId: task.taskId }) } finally { this.updateLastTaskTimestamp() @@ -458,7 +460,7 @@ export abstract class AbstractWorker< data: res, taskPerformance, workerId: this.id, - id: task.id + taskId: task.taskId }) return null }) @@ -471,7 +473,7 @@ export abstract class AbstractWorker< data: task.data }, workerId: this.id, - id: task.id + taskId: task.taskId }) }) .finally(() => {