* @returns The names of the worker's task functions.
*/
public listTaskFunctions (): string[] {
- return Array.from(this.taskFunctions.keys())
+ return [...this.taskFunctions.keys()]
}
/**
* @param message - The received message.
*/
protected messageListener (message: MessageValue<Data>): 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
!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) {
data: res,
taskPerformance,
workerId: this.id,
- id: task.id
+ taskId: task.taskId
})
} catch (e) {
const errorMessage = this.handleError(e as Error | string)
data: task.data
},
workerId: this.id,
- id: task.id
+ taskId: task.taskId
})
} finally {
this.updateLastTaskTimestamp()
data: res,
taskPerformance,
workerId: this.id,
- id: task.id
+ taskId: task.taskId
})
return null
})
data: task.data
},
workerId: this.id,
- id: task.id
+ taskId: task.taskId
})
})
.finally(() => {